Opened 16 years ago
Closed 15 years ago
#7931 closed (invalid)
Debug mode causes template includes to be parsed regardless of if tags
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | template debug include tags | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When running django in debug mode, django appears to parse all template include tags, even if an include tag will never be included. For example:
{% if condition %}
{% include "template_that_will_crash_if_condition_is_false.html" %}
{% endif %}
In DEBUG mode, errors (i.e. loading template tags) in the included template will be thrown, even if the template is never actually included because of the if condition. If debug is not enabled, then no errors are thrown.
The result should be the same whether in debug mode or not.
Change History (5)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:5 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The change in behavior is reliant on settings.TEMPLATE_DEBUG
(which usually is set to the same as DEBUG
).
There is no bug here: the template includes are parsed in both situations, the error is just swallowed silently if not in debug mode.
As to whether the templates *should* always be parsed, we've got #12064 to talk about that now.
#7815 would fix this.
Here's a workaround (since #7815 might be wontfix):