#1338 closed task (fixed)
Undefined context variables should not resolve to the value of TEMPLATE_STRING_IF_INVALID
Description ¶
The new TEMPLATE_STRING_IF_INVALID is a useful setting but it seems to have some problems currently. With the current implementation undefined context variables are actually resolved to the value of TEMPLATE_STRING_IF_INVALID. This means that {% if
some_undefined_variable %} can evaluate true. Also FilterExpression
is passing the
TEMPLATE_STRING_IF_INVALID value through the filters, which is probably not going to fit with user expectations.
Perhaps resolve_variable
should be consistently raising an exception
for all unresolvable variables and Node
renderers and FilterExpression
should be returning TEMPLATE_STRING_IF_INVALID directly where appropriate. This would be slightly backwards
incompatible for people using the guts of the template renderer in their template tags.
Change History (6)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Severity: | normal → major |
---|
I'd say this was a major bug, because it makes this setting -- which could be quite useful for debugging template errors -- virtually useless. It makes all {% if [varname] %} evaluate to true and breaks a lot of logic within the template.
comment:3 by , 19 years ago
Just a note that this is one of the things I fixed in #1400 but that patch seems to have been a little too ambitious to get any loving. Not getting much feedback on what was good and what sucked I didn't get around to breaking the patch down into bite-sized chunks. Unfortunately I no longer have time to work on it at the moment.
comment:4 by , 19 years ago
Owner: | changed from | to
---|
comment:5 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 19 years ago
Component: | Template system → Generic views |
---|---|
priority: | normal → lowest |
Severity: | major → trivial |
Type: | defect → task |
Version: | → SVN |
When I set
in my settings.py, then suddenly inside the admin I won't have the header anymore (the blue bar with "Welcome", documentation, change password, logout, the breadcrumps). So I removed this setting immediately.
I think this is related to this bug.