项目树
pycharm在项目中创建存放xadmin的目录
右键项目名称-->pythonpackage-->输入名称:extra_app
拷贝xadmin代码到extra_app
(mxonline) zhaijunming@zhaijuningdeMBP:~/Desktop/Project/python$ git clone https://github.com/zaxlct/imooc-django.git
(mxonline) zhaijunming@zhaijuningdeMBP:~/Desktop/Project/python$ cp -r imooc-django/extra_apps/xadmin MxOnline/extra_apps/.
配置settings.py
# 设置 apps, extra_apps 目录
sys.path.insert(0,os.path.join(BASE_DIR,'apps'))
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
#添加xadmin app
INSTALLED_APPS = [
'xadmin',
'crispy_forms',
]
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
配置url
MxOnline/urls.py
from django.conf.urls import url
from django.contrib import admin
import xadmin
urlpatterns = [
url(r'^admin/', xadmin.site.urls),
]
生成数据表
makemigrations
migrate
测试
访问127.0.0.1:8000/admin