idlesign / django-siteprefs

Reusable app for Django introducing site preferences system
https://github.com/idlesign/django-siteprefs
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

Improved docs and detection regarding management commands #21

Open jayvdb opened 4 years ago

jayvdb commented 4 years ago

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?

idlesign commented 4 years ago

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.