1👍
✅
The include
template tag supports the passage of arguments using the with
keyword.
parent.html:
{% extends 'base.html' %}
{% block content %}
{% for i in nnn %}
{% include child.html with loop_counter=forloop.counter %}
{% endfor %}
{% end block %}
child.html:
{{ loop_counter }}
Note that you probably don’t actually mean to extend the child template from the same base template as the parent, so I have omitted that in this example.
Source:stackexchange.com