Cycle
- Answer
{% for i in list %}
<li class="{% cycle 'one' 'two' %}">
...
</li>
{% endfor %}
This question is one of 13 in Django template tags and filters. Test yourself on all of them.
Practice quiz FlashcardsExplanations
Produces one of its arguments each time this tag is encountered. The first argument is produced on the first encounter, the second argument on the second encounter, and so forth. Once all arguments are exhausted, the tag cycles to the first argument and produces it again.
Also to mention same value later:
{% cycle 'row1' 'row2' as rowcolors %}
and now use 'rowcolors'.— JackD
Log in to add an explanation.
Advertisement