What are functional differences between DEBUG = True and False in Django?

前端 未结 3 891
小蘑菇
小蘑菇 2021-01-05 18:12

What precisely are the functional differences between toggling the DEBUG setting in a settings.py file of a Django app?

I first assumed

3条回答
  •  盖世英雄少女心
    2021-01-05 18:26

    One of the main advantages of DEBUG=True is of detailed error pages. Django provides a detailed stacktrace of what went wrong. Which is immensely helpful in debugging. Basically, in DEBUG mode, django remembers every SQL query it executes(Which again makes it totally not suitable for production).

    Additionally, if DEBUG=True, host validation is disabled. In other words, if DEBUG=False, ALLOWED_HOSTS needs to be set.

提交回复
热议问题