Either you can use {{forloop.counter |add: forloop.parentcounter.counter }} but depend on the situation if you want to reset the counter then you need to write your own custom python method and later you can call it from django template.
Like in your views add-
class make_incrementor(object):
count = 0
def __init__(self, start):
self.count = start
def inc(self, jump=1):
self.count += jump
return self.count
def res(self):
self.count = 0
return self.count
def EditSchemeDefinition(request, scheme_id):
iterator_subtopic = make_incrementor(0)
scheme_recs = scheme.objects.get(id=scheme_id)
view_val = {
'iterator_subtopic': iterator_subtopic,
"scheme_recs": scheme_recs,
}
return render(request, "edit.html", view_val)
Later in your django template we can call "iterator_subtopic" methods to increment or reset its value like:-
<td id="subTopic" class="subTopic">
<p hidden value="{{ iterator_subtopic.res }}"></p>
{% for strand in scheme_recs.stand_ids.all %}
{{ iterator_subtopic.res }}
{% for sub_strand in strand.sub_strand_ids.all %}
{% for topic in sub_strand.topic_ids.all %}
{% for subtopic in topic.sub_topic_ids.all %}
<input id="subTopic{{ iterator_subtopic.inc }}" class="len"
value="{{ subtopic.name }}">
<br>
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
So It will keep incrementing the value and also we can reset it where we want.