[Answer]-Django dynamically change index in template

1๐Ÿ‘

I will assume you missed in your question percentages.0 instead percentages.i. In a for on template, you can access the index with forloop variable. Like this:

{% for test in page.object_list %}
    {{ forloop.counter }}   # This will start at 1
    {{ forloop.counter0 }}  # This will start at 0
    # do something here
{% endfor %}

See: this answer

๐Ÿ‘คGocht

Leave a comment