I'm writing my first real project in Django and I have a problem with properly setting DEBUG
in development and production. In my settings.py
project file I have:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DJANGO_DEBUG', 'True') == 'True'
So I expect that it should work as follows. By default DEBUG
is set to True
(I use this in my development). But on my production server I have an environmental variable DJANGO_DEBUG
set to "False"
so Django should set DEBUG
to False
.
But this does not work! When I go to my_website/notexistingurl
I see Django detail error page which says that I have DEBUG
set to True
in my settings.py
file. And to make this completely unclear to me, when I open a python shell on my server it says that os.environ.get('DJANGO_DEBUG', 'True') == 'True'
is False
.
Does anyone have an idea what I am missing? Because to me it looks like two completely contradictory things!