Answers for "for counter django"

2

counter in django template

{{ forloop.counter }}   ->  The current iteration of the loop (1-indexed)
{{ forloop.counter0 }}  ->  The current iteration of the loop (0-indexed)
Posted by: Guest on January-10-2022
3

django forloop.counter

{% for item in item_list %}
    {{ forloop.counter }} # starting index 1
    {{ forloop.counter0 }} # starting index 0

    # do your stuff
{% endfor %}
Posted by: Guest on March-19-2020

Browse Popular Code Answers by Language