Xadmin 下载地址: https://github.com/sshwsfc/django-xadmin
遇见的错误
错误一:关联关系ForeignKey引发的错误,打开xadmin文件中的模型文件models.py,凡是出现关联关系字段的地方全部加上on_delete=models.CASCADE , 如下图所示:
错误二:模块包名称合并修改引发的错误 提示:ModuleNotFoundError: No module named 'django.core.urlresolvers' ,
这是因为django2.1把from django.core.urlresolvers修改成了django.urls,如下图所示
错误三:出现如下错误提示
将 forms.Field.__init__(self, required,widget, label, initial, help_text, *args, **kwargs) 修改为如图所示
错误四:ImportError: cannot import name 'login' from 'django.contrib.auth.views'
# 将 website.py 中的
from django.contrib.auth.views import login
from django.contrib.auth.views import logout
# 修改为
from django.contrib.auth import authenticate, login, logout
错误五:ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.query'
# django2.1.1版本将xadmin\plugins\filters.py文件中的
from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
# 修改为
from django.db.models.sql.query import LOOKUP_SEP, Query
# 在Django2.0版本中把
from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
# 修改为:
from django.db.models.sql.query import LOOKUP_SEP
from django.db.models.sql.constants import QUERY_TERMS
错误六:ModuleNotFoundError: No module named 'django.contrib.formtools' 导入fromtools错误,版本太低
# 卸载旧版本
pip uninstall django-formtools
# 安装新版本
pip install django-formtools
错误七:ImportError:cannot import name 'password_reset_confirm from 'django.contrib.auth.views'
# 把xadmin\plugins\password.py中的 from django.contrib.auth.views import password_reset_confirm 修改为: from django.contrib.auth.views import PasswordResetConfirmView
再把位于75行左右 return后的 password_reset_confirm修改为 PasswordResetConfirmView,如下图所示:
错误八:AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES'
# 将xadmin\plugins\language.py 中的
if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_CLASSES:
修改为:
if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE:
错误九:ModuleNotFoundError: No module named 'import_export'
安装django-import_export模块
pip install django-import_export
所有评论(0)