Django 1.9 AppRegistryNotReady

384 views
Skip to first unread message

Jonas H

unread,
Sep 28, 2015, 6:57:55 PM9/28/15
to Django developers (Contributions to Django itself)
Hello all,

I'm not sure if it's expected behaviour,  so I thought I'd rather report this here: I've had issues importing multiple (well[ish]-known) 3rd party apps with Django 1.9 that import fine on Django 1.8. The error I'm getting is AppRegistryNotReady, caused by some (indirect) import to some model in the 3rd party app's __init__.py file. I know that importing models before the app is fully loaded has been officially deprecated in 1.7, but it seems to have worked well anyways since then.

One example of such a 3rd party app is https://github.com/chrisglass/django_polymorphic.

So maybe this should be fixed, if possible, for Django 1.9; or deliberately not fixed to force people adhere the "don't import models in __init__" policy.

Jonas

James Pic

unread,
Sep 29, 2015, 5:39:11 AM9/29/15
to django-d...@googlegroups.com
In DAL we mostly moved autocomplete_light/__init__.py to
autocomplete_light/shortcuts.py, and we're trying to make a fuss about
it on internet so that users using google before opening issues find
it :D

It would be great if other libraries used the same renaming for the
sake of consistencies between apps, we've got inspiration from
django.shortcuts so we're trying to be consistent with django too.

FTR: http://blog.yourlabs.org/post/130026251348/django-19-support-for-django-autocomplete-light

Tim Graham

unread,
Oct 17, 2015, 7:47:53 PM10/17/15
to Django developers (Contributions to Django itself)
This seems to be expected behavior, "In other words, your applications’ root packages and the modules that define your application configuration classes shouldn’t import any models, even indirectly." from https://docs.djangoproject.com/en/1.8/ref/applications/#how-applications-are-loaded

You said, "I know that importing models before the app is fully loaded has been officially deprecated in 1.7, but it seems to have worked well anyways since then." Correct, and now that the deprecation has ended, it's no longer permitted.
Reply all
Reply to author
Forward
0 new messages