I have a setup like the following
Tasks
|__ __init__.py
|__ a.py
|__ b.py
|__ c.py
...
Inside the __init__.py file,
from .a import custom1, custom2
from .b import custom3, custom4
I wrote a function within Tasks which requires Tasks to be added as an INSTALLED_APP.
The custom functions however raise django.core.exceptions.AppRegistryNotReady: "Apps aren't loaded yet.".
The traceback leads to a point where one of the custom functions try to import
from django.contrib.auth.models import User
.
Why does this happen, and is there a way to fix this error WITHOUT moving the custom functions out of the __init__.py file?
question from:
https://stackoverflow.com/questions/65947477/custom-functions-in-init-py-cause-django-apps-arent-installed-yet-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…