2

I am trying to upgrade my Django project to Django 2.0, currently the version is 1.8.19. I figured I would do it step by step, firstly upgrading to 1.9, then 1.10 and so on till 2.0. The problem is that I get error message

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 302, in execute
    settings.INSTALLED_APPS
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/conf/__init__.py", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/riddle/tmp1/example-project/app/ad_akumuliatoriai_lt/settings.py", line 140, in <module>
    from apps.frontend.ad_akumuliatoriai.models import Language
  File "/home/riddle/tmp1/example-project/app/apps/frontend/ad_akumuliatoriai/models.py", line 5, in <module>
    from ordered_model.models import OrderedModel
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/ordered_model/models.py", line 20, in <module>
    class OrderedModelBase(models.Model):
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/home/riddle/tmp1/example-project/env/lib/python3.6/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.

I have read the thread: Django upgrading to 1.9 error "AppRegistryNotReady: Apps aren't loaded yet."

I have tried using

import django
django.setup()

at the top of my settings.py file with no luck.

I've made an assumption that the problem is with the third party apps. My main question is, how to start checking for invalid third party apps, since commenting them out one by one does not remove the error. I've checked every app's that I've installed via pip documentation, and added the required lines to the INSTALLED_APPS in settings.py. It seems that some packages, such as django-jquery, django-libsass, django-ordered-model have not been developed for some years, however, according to django==1.9 release date, those apps should have worked on django==1.9 (or maybe that is the mistake of my thinking?).

I am ready to post more information from my project if needed.

My settings.py fragment:

INSTALLED_APPS = (
    'hvad',
    'compressor',
    'filebrowser',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'jquery',
    'tinymce',
    'apps.frontend.ad_akumuliatoriai',
    'ordered_model',
    'geoposition',
)

The output of "pip freeze":

Django==1.9
django-appconf==1.0.2
django-compressor==2.2
django-filebrowser-no-grappelli==3.7.4
django-geoposition==0.3.0
django-hvad==1.8.0
django-jquery==3.1.0
django-libsass==0.7
django-ordered-model==1.4.3
django-tinymce==2.7.0
libsass==0.14.2
Pillow==5.1.0
psycopg2==2.7.4
pytz==2018.3
rcssmin==1.0.6
rjsmin==1.0.12
six==1.11.0
Riddle00
  • 343
  • 3
  • 13
  • `django.setup()` is for use in stand alone scripts. You shouldn't put it in settings. I always wonder why people are trying to add it to settings. Perhaps it's [the question](https://stackoverflow.com/questions/34114427/django-upgrading-to-1-9-error-appregistrynotready-apps-arent-loaded-yet) you linked to. – Alasdair Apr 04 '18 at 17:28

1 Answers1

2

The traceback suggests you are importing a model in your settings.py:

from apps.frontend.ad_akumuliatoriai.models import Language

You shouldn't do this. Remove the import.

Alasdair
  • 298,606
  • 55
  • 578
  • 516