当前位置: 代码迷 >> 综合 >> python 3.6.6 +django2.0+xadmin
  详细解决方案

python 3.6.6 +django2.0+xadmin

热度:59   发布时间:2023-12-14 18:51:48.0

一、已安装安装如下插件

pip install django==2.0
pip install django-crispy-forms
pip install django-import-export
pip install django-reversion
pip install django-formtools==2.1
pip install future==0.15.2
pip install httplib2==0.9.2
pip install six==1.10.0
pip install Pillow
pip install mysqlclient

二、下载xadmin地址:https://github.com/sshwsfc/xadmin/tree/django2

1)将xadmin目录 复制到新建的extra_apps目录中

2)testdjango项目urls.py更改如下

# xadmin的依赖
import xadmin
xadmin.autodiscover()# version模块自动注册需要版本控制的 Model
from xadmin.plugins import xversion
xversion.register_models()from django.conf.urls import url
urlpatterns = [url(r'^adminx/', xadmin.site.urls),
]

3)注册testdjango项目settings.py更改如下

INSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','users','courses','organization','operation',# 新增 xamin主体模块'xadmin',# 新增 渲染表格模块'crispy_forms',# 新增 为模型通过版本控制,可以回滚数据'reversion'
]

4)run manage.py Task 

makemigrations
migrate

4) 启动项目

"D:\Program Files\JetBrains\PyCharm 2018.2.5\bin\runnerw.exe" C:\Users\Administrator\Envs\test1\Scripts\python.exe D:/testdjango/manage.py runserver 8000
Performing system checks...System check identified no issues (0 silenced).You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): reversion.
Run 'python manage.py migrate' to apply them.
April 11, 2020 - 21:04:17
Django version 2.0, using settings 'testdjango.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.