Django 1.7 upgrade error: AppRegistryNotReady: Apps aren't loaded yet

前端 未结 14 771
耶瑟儿~
耶瑟儿~ 2020-12-08 00:13

I am trying to upgrade a project from Django 1.6 to 1.7. I get the following error:

[Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] mod_wsgi (pid=1         


        
相关标签:
14条回答
  • 2020-12-08 00:30

    see http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts

    import django
    django.setup()
    
    0 讨论(0)
  • 2020-12-08 00:30

    For those (like me) who are getting this error from shell:

    Check that you are executing Django's shell and not Python's shell.

    python manage.py shell
    
    0 讨论(0)
  • 2020-12-08 00:36

    In configuration uwsgi application file ( like uwsgi.ini ) replace:

    module = django.core.handlers.wsgi:WSGIHandler()
    

    on

    module=django.core.wsgi:get_wsgi_application()
    
    0 讨论(0)
  • 2020-12-08 00:37

    settings.AUTH_USER_MODEL is a string (that's why you get AttributeError: 'str' object has no attribute '_meta' - it expects a Model) and should be used only on ForeignKey declarations:

    class Article(models.Model):
        author = models.ForeignKey(settings.AUTH_USER_MODEL)
    

    If you want to refer to your user model somewhere else you need to use get_user_model:

    from django.contrib.auth import get_user_model
    
    UserModel = get_user_model()
    
    0 讨论(0)
  • 2020-12-08 00:38

    In my case the error was caused when I upgraded celery to 4.x and I had this in my INSTALLED_APPS: kombu.transport.django. Removing that resolved the issue. Seems it is mostly caused by some incorrect load of django itself.

    0 讨论(0)
  • 2020-12-08 00:40

    I got this error when moving to a different PC and forgetting to install psycopg2 in my venv and when using 'ENGINE': 'django.db.backends.postgresql', in my settings.

    Perhaps it can be useful to someone else.

    0 讨论(0)
提交回复
热议问题