AppRegistryNotReady: Models aren't loaded yet
Closed this issue · 3 comments
Hi, Daniel!
I had got a following error when I manage.py makemigrations
a django project with django-notifs
installed:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/lib/python2.7/dist-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/notifications/models.py", line 23, in <module>
class Notification(models.Model):
File "/usr/local/lib/python2.7/dist-packages/notifications/models.py", line 54, in Notification
User = get_user_model()
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/__init__.py", line 163, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 192, in get_model
self.check_models_ready()
File "/usr/lib/python2.7/dist-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 use Python 2.7.13, Django 1.10.7, django-notifs 2.6.1.
Is this a good idea not to use a django/contrib get_user_model()
, but use directly settings.AUTH_USER_MODEL
as mentioned here?
Thank you!
Yes, that's the recommended approach. I just pushed a commit to fix it and a new release 2.6.2
.
Sadly, I dropped support for python2.7
to python3.4
so I can't guarantee that everything will work in older versions of python and Django.
By the way, why are you using Python2.7
and Django
1.1x.....It's 2019 😄
Hi, Daniel!
Thanks for the fast response and for the fix! It solved the issue for me.
Py2.7 is a legacy in my project. I'm going to switch to Py3 in the nearest future. I hope I'll be in time before Py2.7 stopped supporting :)
I'm glad that it worked for you :-)
Yeah you should definitely upgrade ASAP.