xadmin 报错: ImportError: cannot import name 'SKIP_ADMIN_LOG'
各种百度谷歌搜不到解决方法:
自己面临崩溃边缘,沉下心看Xadmin源码尝试解决之,最后终于搞定:
报错信息:
Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "F:\envs\luffy\lib\site-packages\django\core\management_init_.py", line 381, in execute_from_command_line
utility.execute()
File "F:\envs\luffy\lib\site-packages\django\core\management_init_.py", line 357, in execute
django.setup()
File "F:\envs\luffy\lib\site-packages\django_init_.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "F:\envs\luffy\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "F:\envs\luffy\lib\site-packages\xadmin\apps.py", line 14, in ready
self.module.autodiscover()
File "F:\envs\luffy\lib\site-packages\xadmin_init_.py", line 49, in autodiscover
register_builtin_plugins(site)
File "F:\envs\luffy\lib\site-packages\xadmin\plugins_init_.py", line 41, in register_builtin_plugins
[import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
File "F:\envs\luffy\lib\site-packages\xadmin\plugins_init_.py", line 41, in
[import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
File "c:\users\ncg\appdata\local\programs\python\python36\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
File "
File "
File "
File "F:\envs\luffy\lib\site-packages\xadmin\plugins\importexport.py", line 48, in
from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS
ImportError: cannot import name 'SKIP_ADMIN_LOG'
解决方法:
把 48行复制一行然后注释掉,在49行里 去掉 SKIP_ADMIN_LOG, TMP_STORAGE_CLASS,换成 ImportMixin
为什么要换成这个是因为 ImportMixin 这个类里写了 skip_admin_log 和 tmp_storage_class 方法