Question:
When developing a web resource in django, I decided to use the loginza application. An exception is thrown during setup:
Traceback (most recent call last):
File "manage.py", line 9, in <module>
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist- packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, 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/loginza/models.py", line 7, in <module>
User = get_user_model()
File "/usr/local/lib/python2.7/dist- packages/django/contrib/auth/__init__.py", line 137, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/usr/local/lib/python2.7/dist- packages/django/apps/registry.py", line 199, in get_model
self.check_models_ready()
File "/usr/local/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 read the documentation and checked all the options that are indicated there. https://docs.djangoproject.com/en/dev/ref/applications/#troubleshooting Same result. As soon as I remove the loginza application from INSTALLED_APPS, the project starts immediately without problems.
setting manager.py:
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE","tetrakub.settings.dev")
import django
django.setup()
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv):
We also created our own User class:
AUTH_USER_MODEL = 'registration.CustomerUser'
What could be the problem?
Answer:
Apparently we are talking about this package – django-loginza . The same problem as yours is described here . The author of the package, judging by the comments, fixed this problem, but judging by the pypi, he did not upload the updates. Try removing the package and installing the dev version from GitHub:
pip uninstall django-loginza
pip install -e git+https://github.com/vgarvardt/django-loginza.git#egg=django-loginza