On 08/26/10 11:10, Andrea Imparato wrote:
How can i scan the zipped list in the template page? If I do
{% for f in zip %}
{{ f }}
{% endfor %}
How can I access the second item in the index?
I think since version 1.0, you can just use standard
tuple-unpacking syntax as detailed in the help[1]:
<dl>
{% for thing1, thing2 in zipped_item_passed_from_view %}
<dt>{{ thing1 }}</dt>
<dd>{{ thing2 }}</dd>
{% endfor %}
</dl>
in pre-1.0, I think you had to do
<dl>
{% for pair in zipped_item_passed_from_view %}
<dt>{{ pair.0 }}</dt>
<dd>{{ pair.1 }}</dd>
{% endfor %}
</dl>
to produce the same results.
-tkc
[1]
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.