Is there an easy way to tell Django’s runserver to override a single variable in the settings.py file?
I would love to be able to call:
python manage.py runserver 0.0.0.0:8000 Debug=False
Any thoughts?
Motive: have a particular site where there are hundreds of database queries to show or save a particular page, I’d like to be able to turn off debug quickly without having to edit my settings file (which has the possibility of being forgotten).
I think you have two options
The simplest is probably a custom settings override, something like:
Now, when you want to start without debugging, you’d run:
As an alternative, you could just customise your
manage.pyfile. That imports settings, and passes it to theexecute_manager. If you added some code between the import and the call, you could have it check for extra arguments and alter the settings as needed. It’s a bit more fiddly and prone to break / be forgotten, so I’d suggest the override settings wrapper is probably your best way to go.