使用xadmin遇到的问题&解决
前置:
注意:这里只写出我使用时发现的问题
关联的包
django >= 2.0
django-crispy-forms >= 1.6.0
django-import-export >= 0.5.1
django-reversion >= 2.0.0
django-formtools == 2.1
future == 0.15.2
httplib2 == 0.9.2
six == 1.10.0
下载链接:
https://github.com/sshwsfc/xadmin/tree/django2
问题&解决
注意:问题1 & 2 & 3 详情和解决办法都是一样的,只是发生问题文件位置不同
问题1. ModuleNotFoundError: No module named 'django.core.urlresolvers'
File "D:\Python310\\.virtualenv\test\lib\site-packages\reversion\admin.py", line 13, in <module>
from django.core.urlresolvers import reverse
ModuleNotFoundError: No module named 'django.core.urlresolvers'
解决办法: 把报错的行修改为 from django.urls import NoReverseMatch, reverse
问题2. ModuleNotFoundError: No module named 'django.core.urlresolvers'
File "D:\Python310\.virtualenv\test\lib\site-packages\crispy_forms\helper.py", line 4, in <module>
from django.core.urlresolvers import reverse, NoReverseMatch
ModuleNotFoundError: No module named 'django.core.urlresolvers'
解决办法: 同问题1
问题3. ModuleNotFoundError: No module named 'django.core.urlresolvers'
File "D:\Python310\.virtualenv\test\lib\site-packages\import_export\admin.py", line 16, in <module>
from django.core.urlresolvers import reverse
ModuleNotFoundError: No module named 'django.core.urlresolvers'
解决办法: 同问题1
问题4. SyntaxWarning: "is" with a literal. Did you mean "=="?
File "F:\Pycharm\Casual\Firsttest\extra_apps\xadmin\filters.py",line 205: SyntaxWarning: "is" with a literal.
Did you mean "=="?
以及第551行
解决办法: 都是把 is 修改为 ==
问题5. cannot import name 'allow_lazy' from 'django.utils.functional'
File "D:\Python310\.virtualenv\test\lib\site-packages\django\utils\functional.py",
raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified.
ImportError raised when trying to load 'crispy_forms.templatetags.crispy_forms_utils':
cannot import name 'allow_lazy' from 'django.utils.functional'
解决办法: allow_lazy在django1.10 已弃用,请使用 keep_lazy 方法
出处:https://docs.djangoproject.com/en/1.10/ref/utils/#django.contrib.admin.allow_lazy
问题6. NameError: name 'allow_lazy' is not defined
File "D:\Python310\.virtualenv\test\lib\site-packages\crispy_forms\templatetags\crispy_forms_utils.py",
line 20, in <module>
remove_spaces = allow_lazy(remove_spaces, text_type)
NameError: name 'allow_lazy' is not defined
line 6, 导入错误,from django.utils.functional import allow_lazy
解决办法: 都是把 allow_lazy 修改为 keep_lazy