首页 > 其他 > 详细

Django3.0.3使用Xadmin

时间:2020-02-25 22:26:08      阅读:1097      评论:0      收藏:0      [点我收藏+]

错误1

# ImportError: cannot import name ‘six‘

# 解决方法
pip install six

# 然后找到 Lib\site-packages 下的six.py 复制到 django/utils下面

# 问题解决

错误2

# ImportError: cannot import name ‘python_2_unicode_compatible‘

from django.utils.encoding import force_text, python_2_unicode_compatible
# 改为
from django.utils.encoding import force_text
from django.utils.six import python_2_unicode_compatible

# 问题解决

错误3

# ModuleNotFoundError: No module named ‘django.contrib.staticfiles.templatetags‘

if django.contrib.staticfiles in settings.INSTALLED_APPS:
    from django.contrib.staticfiles.templatetags.staticfiles import static
else:
    from django.templatetags.static import static

# 改为

# if ‘django.contrib.staticfiles‘ in settings.INSTALLED_APPS:
#     from django.contrib.staticfiles.templatetags.staticfiles import static
# else:
from django.templatetags.static import static

# 问题解决

错误4

# TypeError: render() got an unexpected keyword argument ‘renderer‘

# 跟随错误提示

        return widget.render(
            name=self.html_initial_name if only_initial else self.html_name,
            value=self.value(),
            attrs=attrs,
            renderer=self.form.renderer,
        )

# 改为

        return widget.render(
            name=self.html_initial_name if only_initial else self.html_name,
            value=self.value(),
            attrs=attrs,
            # renderer=self.form.renderer,
        )

# 问题解决

注意:

INSTALLED_APPS = [

    django.contrib.admin,
    django.contrib.auth,
    django.contrib.contenttypes,
    django.contrib.sessions,
    django.contrib.messages,
    django.contrib.staticfiles,

    xadmin,
    crispy_forms,
    corsheaders,
    rest_framework,

    home,
]

# 在注册APP的时候 crispy_forms 要放在 xadmin下面否则会报错

 

 

 

 

Django3.0.3使用Xadmin

原文:https://www.cnblogs.com/wtil/p/12363875.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!