Problems migrating project in Django 1.6 to Django 1.7 version

4

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

ERROR
===============================================================
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\VENVs\qty_v4\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "C:\VENVs\qty_v4\lib\site-packages\django\core\management\__init__.py", line 354, in execute
    django.setup()
  File "C:\VENVs\qty_v4\lib\site-packages\django\__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\config.py", line 197, in import_models
    self.models_module = import_module(models_module_name)
  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\VENVs\qty_v4\lib\site-packages\tastypie\models.py", line 32, in <module>
    from tastypie.compat import AUTH_USER_MODEL
  File "C:\VENVs\qty_v4\lib\site-packages\tastypie\compat.py", line 14, in <module>
    User = get_user_model()
  File "C:\VENVs\qty_v4\lib\site-packages\django\contrib\auth\__init__.py", 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\registry.py", line 199, in get_model
    self.check_models_ready()
  File "C:\VENVs\qty_v4\lib\site-packages\django\apps\registry.py", 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
source

1 answer

3

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 manage.py :

# ...

import django
django.setup()

execute_from_command_line(sys.argv)
    
answered by 20.05.2016 в 14:51