【问题标题】:Django raising AppRegistryNotReady after update from to 1.9从更新到 1.9 后 Django 提高 AppRegistryNotReady
【发布时间】:2020-04-07 05:11:45
【问题描述】:

我已经阅读了许多具有相同情况的类似帖子,并尝试了一些建议的事情,如果它们完全相关的话。我刚刚更新到 Django 1.9,我收到了这个回溯:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/django/www/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/opt/django/www/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 302, in execute
    settings.INSTALLED_APPS
  File "/opt/django/www/local/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/opt/django/www/local/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/opt/django/www/local/lib/python2.7/site-packages/django/conf/__init__.py", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/opt/django/www/src/site_aggrigator/__init__.py", line 2, in <module>
    import management
  File "/opt/django/www/src/site_aggrigator/management/__init__.py", line 4, in <module>
    from django.contrib.auth.models import Permission
  File "/opt/django/www/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/opt/django/www/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "/opt/django/www/local/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/opt/django/www/local/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/opt/django/www/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

我的所有应用程序肯定都安装在我的虚拟环境中,因为在我进行更新之前应用程序运行良好。我也在更新之前收到了这个:

/opt/django/www/local/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/contrib/auth/models.py:41: RemovedInDjango19Warning: Model class django.contrib.auth.models.Permission doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Permission(models.Model):

一篇文章提供了一个解决方案: INSTALLED_APPS = ( "django.contrib.auth.models.Permission",

我也按照他们所说的那样做,这是一个可行的解决方案。其他人有这个问题吗?

【问题讨论】:

    标签: python django django-1.9


    【解决方案1】:

    尝试添加这个(在声明 SECRET_KEY 之后):

    import django
    django.setup()
    

    【讨论】:

    • 嗯,它似乎克服了最后一个错误,但现在又回到了RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. 。我尝试将django.contrib.contenttypes.models.ContentType 添加到我的INSTALLED_APPS
    • 尝试将 'django.contrib.contenttypes' 移动到 installed_apps 的顶部 ..
    • 运气不好:l
    • 再次尝试将已移动的 import django django.setup() 移动到 installed_apps 之后
    • 进步!现在遇到from django.db.models.signals import post_syncdb ImportError: cannot import name post_syncdb
    猜你喜欢
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多