美文网首页
Django错误:RuntimeError: Model cla

Django错误:RuntimeError: Model cla

作者: 创造new_world | 来源:发表于2020-03-30 00:21 被阅读0次

    错误:

            RuntimeError: Model class user.models.UserAccount doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
    
    

    解决方案:

            方案一、删除关于模型层from xxx import UserAccount的引用(不推荐此方法)
    
            方案二、
    
                              检查注册app的settings文件,是否是这样注册的:'apps.user'(apps为装app文件夹)
    
                              检查你引用UserAccount的地方,是否这样引用:from apps.user.models import UserAccount
    
                              检查urls.py的引用是否是这样引用:apps.user.urls
    
    

    若还有错误继续检查有引用模型文件夹下.py文件的地方,

    把 user 的引用改为 apps.user 的引用

    from xxx.apps.users.models import User
    改为
    from users.models import User

    原因网址:

    https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex

    原因:

    Django's Sites Framework is a contributed module bundled with the core library that allows for the use of a single Django application/codebase with different sites (that can use different databases, logic in views, etc). The SITE_ID setting, as stated in the docs, "is used so that application data can hook into specific sites and a single database can manage content for multiple sites."

    In this particular case AllAuth requires the Sites Framework in order to function properly. Many other third-party libraries are built to safely handle cases where multiple sites may be present and as such may be best .

    相关文章

      网友评论

          本文标题:Django错误:RuntimeError: Model cla

          本文链接:https://www.haomeiwen.com/subject/itzpuhtx.html