Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

django

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

I first assumed DEBUG=True merely turned on Django's logging capability and middleware for error reporting, but now I realize that was naive of me. Understanding how the Django internal systems work differently under the two boolean settings helps to form hypotheses when dealing with difficult to debug, plain status 500 errors

like image 508
ecoe Avatar asked Sep 04 '14 23:09

ecoe


1 Answers

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.

like image 126
doubleo Avatar answered Oct 06 '22 14:10

doubleo