#25574: A minor enhancement to "for" tag description in the reference
-------------------------+-------------------------------------------------
     Reporter:  wodny    |      Owner:  nobody
         Type:           |     Status:  new
  Uncategorized          |
    Component:           |    Version:  1.8
  Documentation          |   Keywords:  for tag lookup order dict
     Severity:  Normal   |  defaultdict
 Triage Stage:           |  Has patch:  0
  Unreviewed             |
Easy pickings:  0        |      UI/UX:  0
-------------------------+-------------------------------------------------
 I would like to propose a minor enhancement to a
 [https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for
 paragraph] which gives an example on using the "for" tag with
 dictionaries:
 {{{#!django
 {% for key, value in data.items %}
     {{ key }}: {{ value }}
 {% endfor %}
 }}}
 Currently it doesn't recall the reader that the lookup order would cause
 different output if the "dict" dictionary contains the "items" key than
 when it doesn't.

 On the other hand a paragraph about defaultdict on
 [https://docs.djangoproject.com/en/1.8/ref/templates/language/#variables
 another page] suggests using dict instead of defaultdict. But while it
 solves the problem of creating an entry by making a lookup it doesn't
 solve the problem of "items" key within a dictionary.

 I thought that maybe one or both pages could contain a reminder that the
 view author should remember not to pass a dictionary with the "items" key
 if the template author wants to use that "for key, value" construct.

--
Ticket URL: <https://code.djangoproject.com/ticket/25574>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.d9f15a5b230418bd11b5f7da605d4803%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to