Marcin Szamotulski
unread,Jan 26, 2014, 6:39:42 AM1/26/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django Developers
Hello,
I ask the question here since it is about the developed Django-1.7
version but if you think that I should ask it at django-users then
please excuse me.
When I use get_user_model in a top level of another app models I got an
error :
>>> django.setup()
File "<stdin>", line 1, in <module>
File "/home/coot/webapps/social_feel/venv/src/django/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/coot/webapps/social_feel/venv/src/django/django/apps/registry.py", line 105, in populate
app_config.import_models(all_models)
File "/home/coot/webapps/social_feel/venv/src/django/django/apps/base.py", line 180, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/coot/webapps/social_feel/venv/src/django-registration/registration/models.py", line 15, in <module>
User = get_user_model()
File "/home/coot/webapps/social_feel/venv/src/django/django/contrib/auth/__init__.py", line 133, in get_user_model
user_model = apps.get_model(app_label, model_name)
File "/home/coot/webapps/social_feel/venv/src/django/django/apps/registry.py", line 182, in get_model
self.check_ready()
File "/home/coot/webapps/social_feel/venv/src/django/django/apps/registry.py", line 118, in check_ready
raise RuntimeError("App registry isn't ready yet.")
This because in Django 1.7 get_user_model is using apps.get_model which
checks if registry is ready, while the registry isn't, because it is
being built. So the question is how, in a reusable app get the
configured user model when the registry is not yet ready?
Cheers,
Marcin