• django安装xadmin中出现的报错汇总


    报错一:ModuleNotFoundError: No module named 'django.core.urlresolvers'

    1 ModuleNotFoundError: No module named 'django.core.urlresolvers'

    解决方法:按照提示找到出错的文件, 将所有 import django.core.urlresolvers 改成 import django.urls

    import django.core.urlresolvers 
    
    #改成
    import django.urls

    报错二:TypeError: __init__() missing 1 required positional argument: 'on_delete'

    TypeError: __init__() missing 1 required positional argument: 'on_delete'

    解决方法:这个基本是models文件中models.ForeignKey()中出错的,按照django文档,在括号里加上on_delete=models.CASCADE

    报错三:TypeError: __init__() takes 1 positional argument but 6 were given

    TypeError: __init__() takes 1 positional argument but 6 were given

    解决方法:提示说在xadminviewsdashboard.py这个文件的,找到

                     forms.Field.__init__(self, required, widget, label, initial, help_text,  *args, **kwargs)

                     改成

                     forms.Field.__init__(self)

     forms.Field.__init__(self, required, widget, label, initial, help_text,  *args, **kwargs)
    
    #改成
    forms.Field.__init__(self)

    报错四:ImportError: cannot import name 'login' from 'django.contrib.auth.views'

    ImportError: cannot import name 'login' from 'django.contrib.auth.views'

    解决方法:提示是在xadminviewswebsite.py", line 5, in <module>
                           from django.contrib.auth.views import login

                     找到位置,将

                       from django.contrib.auth.views import login
                       from django.contrib.auth.views import logout

                    改为

                      from django.contrib.auth import authenticate, login, logout

    from django.contrib.auth.views import login
    from django.contrib.auth.views import logout
    
    #改为
    from django.contrib.auth import authenticate, login, logout

     

    报错五: ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.query'

     ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.query'

    解决方法:提示 xadminpluginsfilters.py", line 10, in <module>

                    找到位置,将

         from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS

         改为

           from django.db.models.sql.query import LOOKUP_SEP, Query

    from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
    
    #改为
    from django.db.models.sql.query import LOOKUP_SEP, Query

         

    报错六:ImportError: cannot import name 'password_reset_confirm' from 'django.contrib.auth.views'

    ImportError: cannot import name 'password_reset_confirm' from 'django.contrib.auth.views'

    解决方法:提示xadminpluginspasswords.py", line 4, in <module>
                      找到    from django.contrib.auth.views import password_reset_confirm

         改为    from django.contrib.auth.views import PasswordResetConfirmView

           找到77行,将   return password_reset_confirm

                                        改为   return PasswordResetConfirmView

    from django.contrib.auth.views import password_reset_confirm
    #改为   
    from django.contrib.auth.views import PasswordResetConfirmView
    
    #找到77行  
    return password_reset_confirm
    #改为   
    return PasswordResetConfirmView

        

    报错七:AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES'

    AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES'

    解决方法:提示    xadminpluginslanguage.py", line 24, in <module>
                               if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_CLASSES:

                       改为 if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE:

    if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE_CLASSES:
    #改为 
    if settings.LANGUAGES and 'django.middleware.locale.LocaleMiddleware' in settings.MIDDLEWARE:

     还有别的错误多为 ModuleNotFoundError: No module named,根据提示安装相应模块就行,安装了还不行可能是模块名写错。

  • 相关阅读:
    Essential C++ 3.1 节的代码练习——哨兵方式
    Essential C++ 3.1 节的代码练习——指针方式
    《搞不定人,你如何带团队?》读书记录
    selenium+python,解决selenium弹出新页面,无法定位元素的问题(报错:Unable to locate element:元素)
    selenium 元素(class_name、link_text、css_selector)定位方法
    selenium+python+eclipse 实现 “问卷星”网站,登录与检查登录示例!
    selenium IDE中log的保存与查看方法
    selenium IDE工具页面介绍!
    selenium IDE 使用方法整理
    selenium IDE的3种下载安装方式
  • 原文地址:https://www.cnblogs.com/hanzg/p/11817198.html
Copyright © 2020-2023  润新知