3👍
You want the cycle tag.
{% for object in objects %}
<li class="{% cycle "your-left-class" "your-right-class" %}">
{{object}}
</li>
{% endfor %}
-1👍
{% for object in objects %}
<div class="
{% if forloop.counter % 2 == 0 %}
pull-left
{% else %}
pull-right
{% endif %}
">
{{object}}
</div>
{% endfor %}
Check the for loop in templates.
- [Answered ]-Django Rest Framework – Nested Serialization with intermediary model
- [Answered ]-Most efficient way to store a 5 point scale in Django
- [Answered ]-How to pull data into the form when user wants to update his info? django
Source:stackexchange.com