Django2.0错误:RuntimeError: Model class user.models.UserAccount doesn't declare an explicit app_label

Table of Contents

(原创)

错误:

        RuntimeError: [Model](https://so.csdn.net/so/search?q=Model&spm=1001.2101.3001.7020) 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 的引用  

原因网址:

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](https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting- SITE_ID), 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](http://django- allauth.readthedocs.io/en/latest/installation.html) 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 .

0 评论

发表评论

精品游戏◆乐于分享


Title