#3371: Filter to get dict's value by key name
----------------------------------------+-----------------------------------
Reporter: Alex Dedul | Owner: adrian
Status: new | Component: Template system
Version: SVN | Resolution:
Keywords: template filter dict key | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
----------------------------------------+-----------------------------------
Changes (by ubernostrum):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
What does `{{ dict|key:key_name }}` add that `{{ dict.key_name }}` doesn't
already do (the dot syntax already does a dictionary key lookup as the
first attempt to resolve to a value)?
Also, the proposed implementation doesn't meet the standards for built-in
filters: it doesn't catch `KeyError` and so could propagate an exception
all the way back to the template (filters should fail silently -- in this
case the appropriate behavior is to catch `KeyError` and return an empty
string or the value of `TEMPLATE_STRING_IF_INVALID`).
--
Ticket URL: <http://code.djangoproject.com/ticket/3371#comment:1>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---