0

In our process of upgrading our Django project from 1.8 to 1.9 version, we removed all the deprecation warnings/errors according to Django-1.9 release notes. But, after updating the Django version to 1.9 in the project's virtual environment, we got the following error:

Traceback (most recent call last):
File "/home/django/sites/site_dev/conf/site.wsgi", line 46, in application
return get_wsgi_application()(env, start_response_with_id)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/apps.py", line 13, in <module>
from .app_name import update_language_preference
File "/home/accounts.py", line 4, in <module>
from app_name.models.core import UserAccountModel
File "/home/models/core.py", line 8, in <module>
class TimeStampedModel(models.Model):
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 239, in    get_containing_app_config
self.check_apps_ready()
File "/home/django/sites/site_dev/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

We have many installed apps in the project and using PostgreSQL-9.5 database. We know that the apps which have model classes in it, cause this error to occur. The above error even occured when connecting to the database using connection cursor:

django.db.connection.cursor().execute()
  • 1
    Can you post your full traceback? – Sanip May 09 '19 at 11:56
  • Look at the accepted answer to [this question](https://stackoverflow.com/questions/34114427/django-upgrading-to-1-9-error-appregistrynotready-apps-arent-loaded-yet) and see if it helps you. – evergreen May 09 '19 at 14:36
  • Yes, @Sanip I have added the full traceback. – Vinay Kumar Sahu May 09 '19 at 15:46
  • @evergreen This accepted answer didn't work for me. – Vinay Kumar Sahu May 09 '19 at 15:48
  • The traceback shows that `from .app_name import update_language_preference` is triggering models to be imported before all the apps are being loaded. Since you haven't shown any code, we can't suggest any fixes apart from removing that import. It's much harder to help when you use made-up variable names like `app_name`. – Alasdair May 09 '19 at 16:46
  • Can you try removing `from .app_name import update_language_preference` this from your `/home/apps.py` file? This error may be caused because the apps have not yet been loaded but you are trying to import it. – Sanip May 09 '19 at 16:46

0 Answers0