for-loop range use - Django - iterate number in for loop of a template

1 Answers

Also one can use this:

{% if forloop.first %}


{% if forloop.last %}
loop.counter as index

I have the following for loop in my django template displaying days. I wonder, whether it's possible to iterate a number (in the below case i) in a loop. Or do I have to store it in the database and then query it in form of days.day_number?

{% for days in days_list %}
    <h2># Day {{ i }} - From {{ days.from_location }} to {{ days.to_location }}</h2>
{% endfor %}