Opened 16 years ago
Closed 16 years ago
#11238 closed (invalid)
Widespread {% for %} confusion
Reported by: | RantyDave | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I currently get about fourty hits a day to this page - http://www.zedkep.com/blog/index.php?/archives/85-Iterating-over-a-dictionary-in-Django-templates.html. While I'm more than happy to help out the community and my ego appreciates the hits, I do think the world as a whole would be better served by fixing the root problem in the documentation.
So here is it: people don't know how to iterate over dictionaries and merely including
{% for key,value in dictionary.items %}{{ value }}{% endfor %}
as an example would probably fix that. Can this be backported to the 1.0 (and 0.96) docs too? Thanks, Dave.
There is an example in the docs, check out the third code example here:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
Looks like this has been in the docs since June 2007, see [5443].