django DEBUG=False still runs in debug mode

The root cause of issue - False translated to 'False' string not bool.

Used next solution (settings.py):

DEBUG = os.getenv('DEBUG', False) == 'True'

i.e.: in this case DEBUG will set to (bool) True, only if the environment variable is explicitly set to True or 'True'.

Good luck configuring! :)


As a note for others: I had the same problem; I configured my production website on a VM with gunicorn and nginx, following the tutorial for ubuntu 16.04 from the digital ocean documentation.

I wasn't able to turn off the debug mode, even when restarting the nginx systemd's service: the solution was to restart also the gunicorn service:

# systemctl restart nginx gunicorn

Tags:

Django