#22872: Backwards incompatible change: Can't proxy User model: RuntimeError: App registry isn't ready yet. -------------------------------------+------------------------------------- Reporter: jdufresne | Owner: nobody Type: | Status: new Cleanup/optimization | Version: Component: Documentation | 1.7-beta-2 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by wizpig64): I also have an app that uses a user proxy (also with `class MyUser(get_user_model()):`), which i'm porting up to 1.7. Looking through the docs it seemed like using `apps.get_model('app.model')` (equivalent to `apps.get_model('app', 'model')`) was they way to go about proxying to the user model: {{{ from django.apps import apps from django.conf import settings class MyUser(apps.get_model(settings.AUTH_USER_MODEL)): class Meta: proxy = True }}} but this raises "django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet." It looks like this can be worked around by using the longer `apps.get_app_config('app').get_model('model')`. I'm not sure if this is intended behavior or a bug: {{{ user_app, user_model = settings.AUTH_USER_MODEL.split('.') class MyUser(apps.get_app_config(user_app).get_model(user_model)): ... }}} Some caveats: this only works if your model is after the base user model in `INSTALLED_APPS`, and as long as `AUTH_USER_MODEL` only has one dot. I suppose circumvents the whole point of the new app system, so that plus the caveats probably makes it a bad idea to use. Rather than the above, I think a new `get_user_model()` should be made, or a more clear way of doing this should be documented. The above stuff was tested on 1.7c2 and the latest stable/1.7.x as of writing, http://github.com/django/django/commit/0f44d9f9b1. - I also haven't checked any of the implications of this with migrations. Thanks -- Ticket URL: <https://code.djangoproject.com/ticket/22872#comment:5> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.8a405409a60eeb16e8aa296736c7049a%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.