In my Django settings I have the following:
DEBUG = os.environ['DEBUG_VALUE']
Where DEBUG_VALUE = False
However, Django continues to show full error messages when I do this. If I manual add DEBUG = False
it works and shows 500 error.
For some reason Django is ignoring it when I use the os.environ
value.
I have confirmed DEBUG_VALUE
is False but outputting to a file.
I have even tried:
DEBUG = bool(os.environ['DEBUG_VALUE'])
and still shows full errors.
The debug mode (DEBUG=True) is turned on by default in the Django framework. It provides a detailed traceback with the local variables to find out the error with the line numbers. The error can be triggered from the view page by setting the value of assert to False in the view file.
environ in Python is a mapping object that represents the user's environmental variables. It returns a dictionary having user's environmental variable as key and their values as value.
django-environ is the Python package that allows you to use Twelve-factor methodology to configure your Django application with environment variables.
The value of os.environ['DEBUG_VALUE']
is a string and bool('non empty string') == True
.
You should do something similar to:
DEBUG = os.environ['DEBUG_VALUE'] == 'TRUE'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With