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

错误:

        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 class user.models.UserAccount doesn't declare an explicit app_label)