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?
toolbox.py has the comment
and setting
MANAGE_SAFE_COMMANDS
to bypass that.Firstly, the logic for detecting
manage.py
is not very solid. It wont detectpython ./manage.py ...
orpoetry 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?