报错信息:
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 "", line 978, in _gcd_import
File "", line 961, in _find_and_load
File "", line 950, in _find_and_load_unlocked
File "", line 655, in _load_unlocked
File "", line 678, in exec_module
File "", line 205, in _call_with_frames_removed
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'

解决方法:
xadmin报错.png

把 48行复制一行然后注释掉,在49行里 去掉 SKIP_ADMIN_LOG, TMP_STORAGE_CLASS,换成 ImportMixin
为什么要换成这个是因为 ImportMixin 这个类里写了 skip_admin_log 和 tmp_storage_class 方法


# ImportMixin 这个类当中的源码,跳过admin_log
    def get_skip_admin_log(self):
        if self.skip_admin_log is None:
            return getattr(settings, 'IMPORT_EXPORT_SKIP_ADMIN_LOG', False)
        else:
            return self.skip_admin_log

问题的解决方法来自大佬博客:https://www.cnblogs.com/niucunguo/p/14283630.html

分类: 暂无分类 标签: python

评论

暂无评论数据

暂无评论数据

目录