django-siteprefs icon indicating copy to clipboard operation
django-siteprefs copied to clipboard

Improved docs and detection regarding management commands

Open jayvdb opened this issue 4 years ago • 1 comments

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?

jayvdb avatar May 28 '20 07:05 jayvdb

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.

idlesign avatar May 29 '20 14:05 idlesign