On May 29, 6:26 am, ogterran wrote:
> Hi,
> I want to create a row in my table for with 5 products in each row
> I tried to use the modulus with the forloop.counter but it doesn't
> seem to work
>
> {% for product in product_list %}
> {% ifequal forloop.counter%5 0 %}<tr> {% endifequal %}
> <td>{{ product.title }}</td>
> {% ifequal forloop.counter%5 0 %}</tr> {% endifequal %}
> {% endfor %}
This won't help with Django templates, but I can't avoid pointing out
that Jinja2 has by default a loop variable inside "for" [1]. You'd do
something like:
{% for product in product_list %}
{% if loop.index == 5 %}<tr> {% endif %}
<td>{{ product.title }}</td>
{% if loop.index == 5 %}</tr> {% endif %}
{% endfor %}
It is a pretty useful feature. Sorry for the plug. :-/
-- rodrigo
[1] http://jinja.pocoo.org/2/documentation/templates#list-of-control-structures
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---