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

99封情书 提交于 2019-11-28 17:08:58

I had a similar (the same?) isssue when upgrading to Django 1.7. In may case, it was enough to update the wsgi file: replace

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

with

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

I was looking through all these thread to get celery working on windows (with this particular error message) and I just want to emphasize putting

import django
django.setup()

at the top of your tasks.py file, this is finally what got it working for me.

INSTALLED_APPS Had an missing comma in the array, that caused the error for me.

I got this error when I tried to import models from the app's __init__.py, which is not possible.

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

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

on

module=django.core.wsgi:get_wsgi_application()

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()

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.

In my case, I forgot to add one of my sub-applications inside INSTALLED_APPS.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'basketball',
    'basketball.area',
    'basketball.game',
    'basketball.player',
]

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.

In my case SEcret_key was commented by mistake in settings.py

Yura Liashenko

Just reinstall Django using the command line, not in Pycharm helped to me.

It could be any reason. In my case, I updated my python version outside of my virtual environment, but my virtualenv was still the old version, that makes the error. I deleted the env and build it again using the newer version, and it worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!