Is it possible to access the forloop.counter for the outermost for loop in the following template in Django:
{% for outerItem in outerItems %}
{% for item in items%}
<div>{{ forloop.counter }}. {{ item }}</div>
{% endfor %}
{% endfor %}
forloop.counter returns the innermost for loop's counter in the above example
You can use forloop.parentloop
to get to the outer forloop
, so in your case {{forloop.parentloop.counter}}
.