'AppRegistryNotReady' error after Django Upgrade from 1.8 to 1.9 version

82 Views Asked by At

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()
0

There are 0 best solutions below