{% for round in rounds %}
<div id="round_{{forloop.counter}}">
{% for match in r{{forloop.counter}}_matches %}
<p>I am match {{ match }}!</p>
<p>I am one of the matches in round {{round}}!</p>
{% endfor %}
</div>
{% endfor %}
rounds and r1_matches, r2_matches etc. are lists of objects defined in the view that leads to this template.
Obviously, this snippet is showing logically what I want to happen, but it doesn't work for obvious reasons. In lieu of being able to use {{forloop.counter}} inside the second for loop, how can I go about only loading up matches that are a part of the current round?
As a side note, I also have a variable being passed to this template which isn't shown here, called matches, and each match object has a field called round which tells you which round that match belongs in. I figured I would do more of the logic in the view, though, and so I have r1_matches, r2_matches etc. pre-snipped out into their own lists. Point being, if it makes more sense to do something like {% for match|"round={{forloop.counter}}" in matches %} I would gladly do it, but then I STILL need access to the parent loop's counter same as the other way.