Problems migrating project in Django 1.6 to Django 1.7 version


I have serious problems to make my project work in a newer version of Django (from 1.6 to 1.7)

I am working with a virtual environment in which to reinstall all the applications of my project (from my requirements.txt file), except the version of Django == 1.7 (which I replaced by the previous one)

If anyone knows why this may happen, I would appreciate it if you help me

Traceback (most recent call last):
  File "", line 10, in <module>
  File "C:\VENVs\qty_v4\lib\site-packages\django\core\management\", line 385, in execute_from_command_line
  File "C:\VENVs\qty_v4\lib\site-packages\django\core\management\", line 354, in execute
  File "C:\VENVs\qty_v4\lib\site-packages\django\", line 21, in setup
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\", line 108, in populate
  File "C:\VENVs\qty_v4\lib\site-packages\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:\VENVs\qty_v4\lib\site-packages\tastypie\", line 32, in <module>
    from tastypie.compat import AUTH_USER_MODEL
  File "C:\VENVs\qty_v4\lib\site-packages\tastypie\", line 14, in <module>
    User = get_user_model()
  File "C:\VENVs\qty_v4\lib\site-packages\django\contrib\auth\", line 136, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\", line 199, in get_model
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
asked by Ariel Gavegno 20.05.2016 в 03:25

1 answer


Make sure it's not a problem with the WSGI scripts . In previous versions it was used like this:

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

You have to modify it to comply with the updated version:

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

What you can also try is to call the method django.setup() to register your applications. You have to call it from the script that is giving you a problem that in your case would be from :

# ...

import django

answered by 20.05.2016 в 14:51