升级到Django 1.11版时我遇到了这个问题。 这是我为Djagno auth用户模型获得的错误列表。
File "/customer/models/customer.py"
from django.contrib.auth.models import User
File "/environment/lib/python2.7/site-packages/django/contrib/auth/models.py"
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/environment/lib/python2.7/site-packages/django/contrib/auth/base_user.py"
class AbstractBaseUser(models.Model):
File "/environment/lib/python2.7/site-packages/django/db/models/base.py"
app_config = apps.get_containing_app_config(module)
File "/environment/lib/python2.7/site-packages/django/apps/registry.py"
self.check_apps_ready()
File "/environment/lib/python2.7/site-packages/django/apps/registry.py", in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
我在“导入用户”的位置尝试了get_user_model(),但得到了相同的“AppRegistryNotReady('尚未加载应用'。)”错误。
提前感谢您的建议。
编辑:在安装的应用列表后添加Djagno.setup()。我有这个错误:
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS