#16335: Cannot iterate defaultdict in template
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  jacob.ninja.dev@…                  |         Status:  new
                   Type:  Bug        |      Component:  Template system
              Milestone:             |       Severity:  Normal
                Version:  1.3        |       Keywords:
             Resolution:             |      Has patch:  0
           Triage Stage:  Accepted   |    Needs tests:  0
    Needs documentation:  0          |  Easy pickings:  1
Patch needs improvement:  0          |
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * stage:  Unreviewed => Accepted


Comment:

 Indeed, it boils down to the fact that the template language uses the same
 syntax for dictionary and attribute lookups. The resolution order is
 documented here:
 https://docs.djangoproject.com/en/1.3/topics/templates/#variables. It's
 probably a bad idea to change it.

 We could add a note there to warn about objects that accept a dictionary
 lookup with any name, suggesting to convert them to `dict` before passing
 them to the view, in your example:
 {{{
 context['dictionary'] = dict(dictionary)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16335#comment:2>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to