doubleo doubleo - 1 year ago 218
Python Question

Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

This is the traceback on my windows system.

Traceback (most recent call last):
File "D:\AMD\workspace\steelrumors\", line 9, in <module>
File "D:\AMD\Django\django-django-4c85a0d\django\", line 21, in setup
File "D:\AMD\Django\django-django-4c85a0d\django\apps\", line 108, in populate
File "D:\AMD\Django\django-django-4c85a0d\django\apps\", line 197, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python27\lib\importlib\", line 37, in import_module
File "C:\Python27\lib\site-packages\registration\", line 15, in <module>
User = get_user_model()
File "D:\AMD\Django\django-django-4c85a0d\django\contrib\auth\", line 135, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "D:\AMD\Django\django-django-4c85a0d\django\apps\", line 199, in get_model
File "D:\AMD\Django\django-django-4c85a0d\django\apps\", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

And my looks like this:

import os
import sys
import django

if __name__ == "__main__":

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "steelrumors.settings")
from import execute_from_command_line


I get this error when i am trying to use registration app in Django 1.7

Answer Source

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 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download