1

I am migrating a large project from Django 1.8 to Django 1.9, and when I try to run the project, I get a AppRegistryNotReady exception. The traceback for this problem seems completely unhelpful.

Traceback (most recent call last):
  File "/opt/project/myproject/manage.py", line 16, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 176, in fetch_command
    commands = get_commands()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 100, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 71, in get_commands
    for app_config in reversed(list(apps.get_app_configs())):
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "/usr/local/lib/python2.7/dist-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.

Since nothing in the backtrace is my project's code, how can I go about tracking down the source of this problem?

lowtex
  • 707
  • 4
  • 22
  • Check that your app's `__init__.py` files are not importing any models (see [this question](https://stackoverflow.com/questions/36233098/unable-to-import-models-in-init-py-django-1-9-4)). – Alasdair Nov 14 '17 at 23:59
  • The problem might be caused by an app installed from PyPi, which is harder to check than my own code. Is there some way to get python or Django to tell me which app triggered the exception? – lowtex Nov 15 '17 at 00:10
  • As you say, the error is occurring in Django's code, so there isn't a simple way of telling which app is causing the problem. – Alasdair Nov 15 '17 at 10:02

1 Answers1

0

Since this error might occur when you have an app in your INSTALLED_APPS that is not installed properly, try commenting out the apps to try to find which is causing the problem.

NS0
  • 6,016
  • 1
  • 15
  • 14