1👍
✅
I think the best way to do this is use a specific class from date:
<tr {% if date.day|divisibleby:"2" %}class="date_even"{% else %}class="date_odd"{% endif %}>
<td>something</td>
<td>something else</td>
<td>{{ date }}</td>
</tr>
And then with css do the rest
1👍
An alternative to divisibleby
is to use cycle
to just cycle through the classes:
{% for row in table %}
<tr class="{% cycle 'row_odd' 'row_even' %}">
...
- [Answered ]-Basic URL Django Issue
- [Answered ]-How to make reverse URL to current instance of application?
- [Answered ]-Understanding Querysets, creating the perfect database relationship
- [Answered ]-"This field cannot be null" error in a django 1.5 ModelForm
- [Answered ]-ImportError: No module named 'celery' in proj/proj/celery.py
Source:stackexchange.com