24👍
UPDATE this is an excellent answer but it is out of date. See the comment below by @iver56 for a more up-to-date answer.
(updated November 2023 by @avi-flax)
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
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.