6๐
โ
I think you have a couple of options here:
-
Import settings and throw an error to remind yourself to turn debug off.
-
Use the
--settings=
and set that equal to a file (e.g. gen_settings.py) file specifically for your generate_sitemaps command whereDEBUG=False
. Then create an alias for./manage.py generate_sitemaps --settings=gen_settings
http://docs.djangoproject.com/en/dev/topics/settings/ warns specifically to not change the settings at runtime
Iโve used the second option before and it worked fairly well. Better than being annoyed after 2-3 hours =)
๐คdting
1๐
I am not really sure it helps you, but you can try:
from django.conf import settings
tmp = settings.DEBUG
settings.DEBUG = False
# some your actions
# ...
# ...
settings.DEBUG = tmp
Alternatively you can use separated settings file and set it in command line like
./manage.py your_command --settings=another_settings.py
And in that another_settings.py:
from .settings import *
DEBUG = False
๐คMillioner
- [Django]-Fresh mysql database getting "mydb.background_task doesn't exist" โ Django
- [Django]-Kubernetes liveness probe fails when the logs show a 200 response
- [Django]-How to install mod_wsgi on Windows+XAMPP in 2017
- [Django]-Django model.full_clean() allows invalid value for IntegerField
- [Django]-How to read Django request.FILES (which is an image) as binary
Source:stackexchange.com