Answer the question
In order to leave comments, you need to log in
How to combine 3 identical (almost) cycles in a template and display a common ordinal number?
To make it clearer, I will make an example of a model and my template below.
{% for match in matches %}
<div class="match-col">
<div class="match-col__names">
<table class="match-table">
{% for para in match.matchparainstance_set.all %}
<tr class="match-table__tr">
<td class="order">ПОРЯДКОВЫЙ ID</td>
<td class="name">{{ para.para.person }}</td>
</tr>
{% endfor %}
{% for pag in match.matchpaginstance_set.all %}
<tr class="match-table__tr">
<td class="order">ПОРЯДКОВЫЙ ID}</td>
<td class="name">{{ pag.pag.person }}</td>
</tr>
{% endfor %}
{% for pass in match.team.passenger.all %}
<tr class="match-table__tr">
<td class="order">ПОРЯДКОВЫЙ ID</td>
<td class="name">{{ pass.person }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}
class Match(models.Model):
date = models.DateField()
match_name = models.CharField(max_length=255)
team = models.ForeignKey('Team', blank=True, null=True)
class MatchPARAInstance(models.Model):
match = models.ForeignKey('Match')
para = models.ForeignKey('PARA')
class MatchPAGInstance(models.Model):
match = models.ForeignKey('Match')
pag = models.ForeignKey('PAG')
class Team(models.Model):
team_name = models.CharField(max_length=255)
passenger = models.ManyToManyField(PARA)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question