Open jhrr opened 8 years ago
before being able to use Django in a Script (which is not a managment-script) some initialization has to be done in a certain order, so you can use models etc.
Since the setup-format with django-comments is different a modified method has to be used for initializing django - without django-configurations you'd use this: https://docs.djangoproject.com/en/1.9/ref/applications/#django.setup
The documentation could be improved by adding a link do the documentation of django.setup().
I have tasks.py
for uwsgi spooler
, which is handled by uwsgi
.
When I setup it as:
import configurations
configurations.setup()
It works fine, but what if I'm developing reusable application? This app can be used with or without django-configurations
, but I can't use:
from django.apps import apps
if apps.is_installed('configurations'):
import configurations
configurations.setup()
because django-configurations
doesn't need to be listed in INSTALLED_APPS
..
And I can't just check if environment variable for django-configurations
exists, coz it can be just defined, but it doesn't means that project runs via django-configurations
..
I can't try to import too, coz it can be installed, but not used.
How to correctly detect if project runs via django-configurations
or not?
So, this part of the docs is somewhat terse and obscure:
https://django-configurations.readthedocs.org/en/latest/patterns/#standalone-scripts
I'm not sure what it means or why I would want it. Could anyone clarify it for me? I'd be more than happy to update the docs with extra detail once I've understood...