When upgrading django 1.7 to 1.8 (final goal is migrating 1.4 to 1.11LTS) I am asked to remove SOUTH form my INSTALLED_APPS
Fine, but then I get:
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
So I tried to add in settings file:
import django
django.setup()
but it brings this error at runtime, that make me think it is not the proper way:
AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
my INSTALLED_APPS:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'mptt',
# 'south',
'main',
'proxy',
'picocms',
'django.contrib.admin',
'reports',
'django_orphaned'
Note that if I comment 'main' (my main code folder) and 'picocms' (an outdated lib), the AppRegistryNotReady exception is not raised anymore(but obviously the project cannot work without it)
Does someone successfully went through the same kind of issue?
stackTrace (for info)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File ".../workspace/django/cms/main/models.py", line 19, in <module>
from picocms.models import CMSModel, CMSCategory, ActiveModelManager, PublicModelManager
File ".../.virtualenvs/migre/lib/python2.7/site-packages/picocms/models.py", line 13, in <module>
class CMSCategory(MPTTModel):
File ".../.virtualenvs/migre/lib/python2.7/site-packages/mptt/models.py", line 189, in __new__
return meta.register(cls)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/mptt/models.py", line 273, in register
manager.init_from_model(cls)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/mptt/managers.py", line 58, in init_from_model
[tree_field] = [fld for fld in model._meta.get_fields_with_model() if fld[0].name == self.tree_id_attr]
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 56, in wrapper
return fn(*args, **kwargs)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 432, in get_fields_with_model
return [self._map_model(f) for f in self.get_fields()]
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 740, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 802, in _get_fields
all_fields = self._relation_tree
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 709, in _relation_tree
return self._populate_directed_relation_graph()
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/db/models/options.py", line 681, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File ".../.virtualenvs/migre/lib/python2.7/site-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File ".../.virtualenvs/migre/lib/python2.7/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.
I upgraded the picocms deprecated project and switched mptt version to 0.9.0 and it worked.
But indeed, my time would be better spent writing a new version of the project in python 3 and Django 2.2