下载以及配置
下载链接:https://github.com/sshwsfc/xadmin/tree/django2 并将其中的xadmin解压后放入extra_app中,并进行如下的配置:settings.py中的设置
import sys
sys.path.insert(0,os.path.join(BASE_DIR, 'extra_apps'))
INSTALLED_APPS = ['xadmin', 'crispy_forms',]
出错:
from future.utils import iteritems
ModuleNotFoundError: No module named 'future'
解决方法: pip install future
在根目录的url.py中添加如下代码:
urlpatterns = [
path('xadmin/', admin.site.urls),
]
出错:
from crispy_forms.utils import TEMPLATE_PACK
ModuleNotFoundError: No module named 'crispy_forms'
解决方法:
pip install django-crispy-forms
出错:
from django.contrib.formtools.wizard.storage import get_storage
ModuleNotFoundError: No module named 'django.contrib.formtools'
解决方法:
pip install django-formtools
出错:
import httplib2
ModuleNotFoundError: No module named 'httplib2'
解决方法:
pip install httplib2
出错:
import six
ModuleNotFoundError: No module named 'six'
解决方法:
pip install six
出错:
from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS
ModuleNotFoundError: No module named 'import_export'
解决方法:
pip install Collecting django-import-export
出错:
from import_export.admin import DEFAULT_FORMATS,ImportMinxin
ImportError: cannot import name 'ImportMinxin'
解决方法:打开xadmin\plugins\importexport.py
并且修改如下代码:将第48行的代码注释掉
from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS
添加如下代码
from import_export.admin import DEFAULT_FORMATS,ImportMixin
之后进行数据库的迁移:
python manage.py migrate
出现警告:
?: (urls.W005) URL namespace 'admin' isn't unique. You may not be able to reverse all URLs in this namespace
解决方法:在根目录urls.py中删除重复的后台url
已经调配好的带有xadmin的django的后台项目
github地址:
https://github.com/906571331/django2_xadmin_kyx