Heroku Django DEBUG Setting not applicable

I currently have a working Django application for building on Heroku. Unfortunately, I was not able to disable the DEBUG setting on Heroku. Disabling it locally works fine, but when it is pushed into Heroku (after heroku config:set DEBUG=False ), it does not apply.

Error pages are still standard DEBUG instead of the 404, 403, and 500 patterns in our mouse root.

I also tried to use the DJANGO_DEBUG parameter in case of any environmental conflicts with DEBUG and casting the result to a logical value in the settings file. heroku config shows that the settings in the environment are correct. This is on Django 1.3, Keroku Geroku.

Any tips or solutions?

+8
source share
2 answers

Does your django settings.py file even look in the environment?

By default, it does not care about everything that you installed in the environment (via "config: set"). If you are filling the environment into a logical one, make sure that you have done it correctly. bool ('False') is still true.

The easiest way is to simply determine if an environment variable exists, so you don’t have to worry about the type or specific configuration formats.

DEBUG = os.environ.get('DEBUG', False)

To disable debug, remove the variable from the environment instead of trying to type ... it just seems more reliable and reliable. config:unset DEBUG

+13
source

The problem is that the environment variable is not a boolean, but a string. So put below line in settings.py

DEBUG_VALUE = (os.environ.get('DEBUG_VALUE') == 'True')

0
source

Source: https://habr.com/ru/post/943794/


All Articles