其他分享
首页 > 其他分享> > django3.1.1 集成 xadmin0.6.1 时出现的兼容问题集锦

django3.1.1 集成 xadmin0.6.1 时出现的兼容问题集锦

作者:互联网

1. No module named 'django.core.urlresolvers'
    解决办法:
        将:
            django.core.urlresolvers 
        修改为:
            django.urls

2.  cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding'
    解决办法:
        将:
            django.utils.encoding 
        修改为:
            django.utils.six

3. cannot import name 'smart_text' from 'django.utils.encoding'
    解决办法:
        将:
            django.utils.encoding
        修改为:
            django.utils.encoding

4. No module named 'django.contrib.staticfiles.templatetags'
    解决办法:
        将:
            django.contrib.staticfiles.templatetags、
        修改为:
            django.templatetags.static

5. init() missing 1 required positional argument: 'on_delete'
    解决办法:
        在外键 ForeignKey 的地方加上 on_delete=models.CASCADE

6.  init() takes 1 positional argument but 6 were given
    解决办法:
        将:xadmin.views.dashboard.py 文件中的
            forms.Field.__init__(self, required, widget, label, initial, help_text, *args, **kwargs)
        修改为:
            forms.Field.__init__(self)

7. cannot import name 'login' from 'django.contrib.auth.views'
    解决办法:
        将 
            from django.contrib.auth.views import login
            from django.contrib.auth.views import logout
        修改为:
            from django.contrib.auth.views import LoginView as login
            from django.contrib.auth.views import LogoutView as logout

8. cannot import name 'QUERY_TERMS' from 'django.db.models.sql.query'
    解决办法: QUERY_TERMS 字段名字变成了 Query
        from django.db.models.sql.query import Query as QUERY_TERMS

9. cannot import name 'password_reset_confirm' from 'django.contrib.auth.views'
    解决办法:
        将:
            from django.contrib.auth.views import password_reset_confirm
        修改为:
            from django.contrib.auth.views import PasswordResetConfirmView as password_reset_confirm

10. '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:

11. cannot import name 'FieldDoesNotExist' from 'django.db.models'
    解决办法:
        将 FieldDoesNotExist 独立进行导入,需要删除原本该类的导入
        from django.core.exceptions import FieldDoesNotExist

标签:解决办法,xadmin0.6,兼容问题,views,auth,django,集锦,contrib,import
来源: https://blog.csdn.net/Deeply_bless/article/details/112586936