Answers for "iterate numbers in django template"

2

template for loop iteration number

{% 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
2

django template for range

{% with ''|center:n as range %}
{% for _ in range %}
    {{ forloop.counter }}
{% endfor %}
{% endwith %}
Posted by: Guest on October-16-2020

Code answers related to "iterate numbers in django template"

Python Answers by Framework

Browse Popular Code Answers by Language