I have a table with 9 values. I want to loop through the table and put the results into a div structure in the template.
I tried to cycle through them, but I wasn’t able to put them into different divs.
The following works to put the same value in both places. How can I increment to the next group_nm?
{% for g in groups %}
<div class="left1">
<a href="/group/{{ g.group_nm }}">
<img src="/site_media/images/groups/{{ g.group_nm }}.gif" height="125px" width="200em" />
</a>
<p align="center">
<font size="5" face="Georgia, Arial" color="maroon">
{{ g.group_nm }}
</font>
</p>
</div>
<div class="left2">
<a href="/group/{{ g.group_nm }} ">
<img src="/site_media/images/groups/{{ g.group_nm }}.jpg" height="125px" width="200em" />
</a>
<p align="center">
<font size="5" face="Georgia, Arial" color="maroon">
{{ g.group_nm }}
</font>
</p>
</div>
Thanks.
EDIT: I want to do this with 9 groups (eventually, in another place, I’ll want to do it with an unlimited number). The above example only shows an example of 2 that are repeated.
Resolved it, but only if I know the number of rows that will be returned. This is will not work with unlimited numbers and isn’t as elegant as I want, but it’ll do.
I used the ifequal forloop.counter which I found in the django google group.
and on through all 9 groups.