#17664: {% if %} template tag silences exceptions inconsistently
-------------------------------------+-------------------------------------
Reporter: Tai Lee | Owner: Robert
| Roskam
Type: Bug | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: smart if tag | Triage Stage: Accepted
queryset exception silenced |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):
So current PR removes the ability to silently move over undefined
variables. As such it requires changes to check if a variable is defined
before accessing it in the template:
{{{
{% if request and model.admin_url and model.admin_url in request.path %}
}}}
Where the `{% if request and model.admin_url and ...` is new.
For me this would be a major change to the (historic) behaviour of the
DTL, and a major step back in usability. It's an age old feature to be
able to define blocks that simple don't show if the variable is missing.
(The number of place is used must be legion.)
Beyond that the `if var and var.attr` pattern is horribly boilerplate-y.
(IMO)
Is there a way we can allow genuine exceptions to raise whilst maintaining
the behaviour of allowing variables to be undefined, passing only on a
missing lookup, say? What would that look like?
I think we'd need significantly more light on the discussion before making
the suggested change: we need to be sure we've realised what the change
really entails.
Hope that makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/17664#comment:27>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.982c75953b6017f1da0185330b05f9e3%40djangoproject.com.