Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
Running these commands solved my problem (credit to this answer):
import django
django.setup()
However I'm not sure why I need this. Comments would be appreciated.
This is what solved it for us and these folks:
Our project started with Django 1.4, we went to 1.5 and then to 1.7. Our wsgi.py looked like this:
import os
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
application = WSGIHandler()
When I updated to the 1.7 style WSGI handler:
import os
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
application = get_wsgi_application()
Everything works now.
The issue is in your registration app. It seems django-registration calls get_user_module()
in models.py
at a module level (when models are still being loaded by the application registration process). This will no longer work:
try:
from django.contrib.auth import get_user_model
User = get_user_model()
except ImportError:
from django.contrib.auth.models import User
I'd change this models file to only call get_user_model()
inside methods (and not at module level) and in FKs use something like:
user = ForeignKey(settings.AUTH_USER_MODEL)
BTW, the call to django.setup()
shouldn't be required in your manage.py
file, it's called for you in execute_from_command_line
. (source)