I am a new Python and Django user, but I have a good deal of
experience in other languages. I am trying to create a zebra table
(alternating colors for list items or table rows). The way I would
normally go about this is
<ul>
{% for greeting in greetings %}
{% if forloop.counter % 2 %}
<li class="odd">
{% else %}
<li>
{% endif %}
On {{ greeting.date }},
{% if greeting.author %}
<b>{{ greeting.author.nickname }}</b>
wrote:
{% else %}
an anonymous person wrote:
{% endif %}
{{ greeting.content|escape }}
</li>
{% endfor %}
</ul>
But, of course, the if statement can only test a variable for truth.
Is there a way to do this in the template, or am I going to have to
resort to stupid JavaScript tricks?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---