Changes between Version 1 and Version 2 of Ticket #31560, comment 3
- Timestamp:
- Jul 3, 2020, 4:43:26 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31560, comment 3
v1 v2 2 2 > Thanks for this report, Can you provide a sample project? All my attempts raise an `ImportError` (even with circular imports in `apps.py`) 3 3 4 I had this problem and managed to debug it right now. It will happen when Django's app registry imports the app's module added in INSTALLED_APPS and that module imports, directly or indirectly, a model of the app being loaded . Reading the docs [https://docs.djangoproject.com/en/3.0/ref/applications/] there are no notes warning about it. 4 5 Edit: Django docs [https://docs.djangoproject.com/en/3.0/ref/applications/#initialization-process] states that models must not be imported during apps population time. 6 So the OP should check whether models are being imported. 5 7 6 8 **Steps to reproduce** … … 10 12 4. Add the app's dotted path to INSTALLED_APPS 11 13 5. Try to run with {{{ ./manage.py runserver }}} 12 You will get the error {{{ django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. }}}. At a model's import time, the model metaclass will check whether its app is ready, but it is not, so the AppRegistryNotReady will be raised since the registry is being populated.13 14 Since it's caused by Django, I think Django should be able to detect it and output a meaning error message