On Fri, Nov 25, 2011 at 1:32 PM, marjenni <[email protected]> wrote:
> Thank you for the quick reply :)
>
> What I am currently doing is passing 3 separate lists to the template,
> each representing the column of a table so that i can do something
> this:
>
> {% for i in numberOfImages %}
> <tr>
> <td> {{ images.i}} </td>
> <td> {{ descriptions.i}} </td>
> <td> {{ links.i}} </td>
>
> What is the best way to do this then?
>
> many thanks
>
> Mark
>
zip them together:
from itertools import izip
rows = izip(images, descriptions, links)
{% for row in rows %}
{{ row.0 }} (image)
{{ row.1 }} (description)
{{ row.2 }} (link)
izip does it as an iterator, so there is no overhead involved.
Cheers
Tom
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.