django xdmin使用
Posted 北漂的雷子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django xdmin使用相关的知识,希望对你有一定的参考价值。
我们来看看我们原先django给我们自带的admin后台是什么样子的呢
有人说,你的界面怎么那么丑,我说这个还叫丑吗,他说丑,我说你来,我看看你的,上图
看到登录界面后,我说别看了,我去修改,修改,我的于是乎,我也开始了对我的进行了修改,找资料,可惜都是python2的 我的装不上,抓狂,费了九牛二虎之力,于是乎,我的也搞好了,
比人的都是
pip install xadmin
我的是3,找到了相关衔接,链接: https://pan.baidu.com/s/1qYkJy3q 密码: i42m
那么我的我给放到了public的目录下面,接着就是我来配置我的xadmin了,在setting配置下面
import os import sys sys.path.insert(0, BASE_DIR) sys.path.insert(0, os.path.join(BASE_DIR, \'public\'))
在INSTALLED_APPS配置如下
INSTALLED_APPS = [ \'django.contrib.admin\', \'django.contrib.auth\', \'django.contrib.contenttypes\', \'django.contrib.sessions\', \'django.contrib.messages\', \'django.contrib.staticfiles\', \'blog\', \'xadmin\', ]
运行报错提示没有crispy_forms 这可怎么办,这是哪里来的 百度啊,百度看看,
进行安装,安装好,还是不行,少啥安装啥,但是报错,
去下载包 然后用
这么来安装就成功了,
成功之后呢,配置上,在setting配置上
\'crispy_forms\',
\'reversion\',
但是还是不对,还缺少 DjangoUeditor ,上面我给的链接也有,下载就可以直接进行安装,然后配置完,可以正常启动了,。
在url目录下这么配置。
from django.conf.urls import url from django.contrib import admin import xadmin urlpatterns = [ # url(r\'^admin/\', admin.site.urls), url(r\'^xadmin/\', xadmin.site.urls), ]
这样我的xadmin也生效了
python manage.py makemigrations
python manage.py migrate
同步数据库后,增加了部分表,
我们接着启动访问就好。
登录后
这样我的后台也和别人的一样了,高大上了。体验一番,感觉还不错,上手还挺快。
setting配置全文 """ Django settings for blog_project project. Generated by \'django-admin startproject\' using Django 1.10.1. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os import sys import os import socket # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, BASE_DIR) sys.path.insert(0, os.path.join(BASE_DIR, \'public\')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = \'2nq*)__r9p-n(b^)07wf_(6*di6e3_1rt^ljfdb)5sz-+q@hrd\' # SECURITY WARNING: don\'t run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ \'django.contrib.admin\', \'django.contrib.auth\', \'django.contrib.contenttypes\', \'django.contrib.sessions\', \'django.contrib.messages\', \'django.contrib.staticfiles\', \'blog\', \'xadmin\', \'crispy_forms\', \'reversion\', \'DjangoUeditor\' ] MIDDLEWARE = [ \'django.middleware.security.SecurityMiddleware\', \'django.contrib.sessions.middleware.SessionMiddleware\', \'django.middleware.locale.LocaleMiddleware\', \'django.middleware.common.CommonMiddleware\', \'django.middleware.csrf.CsrfViewMiddleware\', \'django.contrib.auth.middleware.AuthenticationMiddleware\', \'django.contrib.messages.middleware.MessageMiddleware\', \'django.middleware.clickjacking.XFrameOptionsMiddleware\', ] ROOT_URLCONF = \'blog_project.urls\' TEMPLATES = [ { \'BACKEND\': \'django.template.backends.django.DjangoTemplates\', \'DIRS\': [os.path.join(BASE_DIR, \'templates\')], \'APP_DIRS\': True, \'OPTIONS\': { \'context_processors\': [ \'django.template.context_processors.debug\', \'django.template.context_processors.request\', \'django.contrib.auth.context_processors.auth\', \'django.contrib.messages.context_processors.messages\', \'blog.views.global_setting\', ], }, }, ] WSGI_APPLICATION = \'blog_project.wsgi.application\' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { \'default\': { \'ENGINE\': \'django.db.backends.sqlite3\', \'NAME\': \'blog.db\', \'USER\':\'\', \'PASSWORD\':\'\', \'HOST\':\'\', \'PORT\':\'\', } } # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { \'NAME\': \'django.contrib.auth.password_validation.UserAttributeSimilarityValidator\', }, { \'NAME\': \'django.contrib.auth.password_validation.MinimumLengthValidator\', }, { \'NAME\': \'django.contrib.auth.password_validation.CommonPasswordValidator\', }, { \'NAME\': \'django.contrib.auth.password_validation.NumericPasswordValidator\', }, ] # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = \'en-us\' TIME_ZONE = \'Asia/Shanghai\' USE_I18N = True USE_L10N = True USE_TZ = False # Static files (CSS, javascript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ AUTH_USER_MODEL=\'blog.User\' #MEDIA_URL=\'/uploads/\' #MEDIA_ROOT=(os.path.join(BASE_DIR,\'uploads\'),) STATIC_URL = \'/static/\'
以上是关于django xdmin使用的主要内容,如果未能解决你的问题,请参考以下文章
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段