django-siteprefs
django-siteprefs copied to clipboard
Improved docs and detection regarding management commands
toolbox.py has the comment
Do not discover anything if called from manage.py (e.g. executing commands from cli).
and setting MANAGE_SAFE_COMMANDS
to bypass that.
Firstly, the logic for detecting manage.py
is not very solid.
It wont detect python ./manage.py ...
or poetry run python manage.py ...
, 'django-admin ...` , etc, etc.
Perhaps there is a flag inside Django management command tooling to help detect this without arg parsing.
But more importantly, why "not discover anything if called from manage.py"? Is this to avoid triggering some bug / incompatibility with other parts of Django?
It sounds a little scary that some part of the settings initialisation is not performed sometimes. Will the settings be different if I invoke a management command with different CLI invocation mechanism?
MANAGE_SAFE_COMMANDS
was a dirty workaround for something indeed.
Will try to recall for what in more detail, when came back after the weekends.