django DEBUG=False still runs in debug mode

前端 未结 9 664
再見小時候
再見小時候 2021-01-12 21:45

I\'m having issues setting my DEBUG = False on my deployed server (on heroku).

I don\'t believe I\'ve seen this before, but setting debug to false is not

相关标签:
9条回答
  • 2021-01-12 22:23

    I also experienced this problem as I was loading the debug setting from an environment variable DEBUG = os.environ.get('DEBUG_MODE')).

    This set the DEBUG value as a string, not a boolean.

    To fix this, I hardcoded DEBUG = False in my prod settings file.

    0 讨论(0)
  • 2021-01-12 22:29

    When you use the module decouple (pip install python-decouple) make sure you cast DEBUG to a bool. Thus settings.py should have the following line:

    from decouple import config
    
    DEBUG = config('DEBUG', default=False, cast=bool)
    

    where in the .env file

    DEBUG = False # or True
    
    0 讨论(0)
  • 2021-01-12 22:30

    This ended up being an issue with the config variable being "False" instead of False, and so debug wasn't properly set to the boolean value. Shoutout to @WithNail for helping get to the answer

    0 讨论(0)
提交回复
热议问题