I have been trying to find information about this setting but there isn't much. Can someone explain me what is this setting about? Should I turn it off in production?... Just want to learn about it, maybe I'm missing something important in django.
(I use django 1.6)
This setting helps with debugging errors/exceptions raised while rendering the templates.
If it is set to True
and DEBUG
is True
, Django would show you usual "fancy" error page with a traceback, request details and other important information, and highlight at which line the error happened.
If it is set to False
and DEBUG
is True
and there was an error while rendering the template, you would still see the Django's error page, but it would miss the block containing template code where the error occurred. So it would be more difficult to debug.
It is a good practice to make sure the value of TEMPLATE_DEBUG
is the same as DEBUG
(though if DEBUG
is False
, the error page would not be shown):
DEBUG = TEMPLATE_DEBUG = True # development
DEBUG = TEMPLATE_DEBUG = False # production
Documentation reference.
Example.
Imagine we have an error in the template, forgot to provide the date format in the now
template tag:
<div>
<span class="date">
{% now %}
</span>
</div>
DEBUG
is set to True
.
In case of TEMPLATE_DEBUG=True
the Django's fancy error page would contain the following block:
If TEMPLATE_DEBUG=False
, this block would not be visible.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With