Current iteration of a for loop in a Django template - forloop.counter


Django tip:

You can use counter to get the current iteration of a for loop in your Django templates like so:

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