我想按比赛名称分组 我按等级排序,但是我未能按比赛分组。 您应该向我建议什么[看起来您的帖子大部分是代码;请添加更多详细信息。] [看来您的帖子大部分是代码;请添加更多详细信息。] [看来您的帖子大部分是代码;请添加更多详细信息。](对不起,垃圾邮件)
html
<!-- TABLE -->
<div class="table standings">
<!-- TABLE ROW HEADER -->
<div class="table-row-header">
<!-- TABLE ROW HEADER ITEM -->
<div class="table-row-header-item position">
<p class="table-row-header-title">{{ team.broyale_match.name }}</p>
</div>
<!-- /TABLE ROW HEADER ITEM -->
<div class="table-row-header-item padded">
<p class="table-row-header-title">Maç</p>
</div>
<div class="table-row-header-item padded">
<p class="table-row-header-title">Sırası</p>
</div>
</div>
<!-- /TABLE ROW HEADER -->
{% for team in teams %}
<!-- TABLE ROWS -->
<div class="table-rows">
<!-- TABLE ROW -->
<div class="table-row">
<!-- TABLE ROW ITEM -->
<div class="table-row-item position">
<!-- TABLE TEXT -->
<p class="table-text">{{ forloop.counter }}</p>
<!-- /TABLE TEXT -->
<!-- TEAM INFO WRAP -->
<div class="team-info-wrap">
<!-- TEAM LOGO -->
<img class="team-logo small" src="{% static 'img/flags/' %}{{ team.team.country_code }}.svg" alt="{{ team.team.country_code }}">
<!-- /TEAM LOGO -->
<!-- TEAM INFO -->
<div class="team-info">
<p class="team-name">{{ team.team.name }}</p>
<p class="team-country">{{ team.team.country }}</p>
</div>
<!-- /TEAM INFO -->
</div>
<!-- /TEAM INFO WRAP -->
</div>
<!-- /TABLE ROW ITEM -->
<div class="table-row-item">
<p class="table-text bold"> {{ team.broyale_match.name }}</p>
</div>
<div class="table-row-item">
<p class="table-text bold">{{ team.rank }}</p>
</div>
</div>
<!-- /TABLE ROW -->
</div>
<!-- /TABLE ROWS -->
{% endfor %}
</div>
<!-- /TABLE -->
models.py
class BroyaleMatchTeam(models.Model):
broyale_match = models.ForeignKey('BroyaleMatch', on_delete=models.CASCADE)
team = models.ForeignKey(Team, on_delete=models.CASCADE)
rank = models.IntegerField(default=40)
views.py
teams=BroyaleMatchTeam.objects.filter(
broyale_match__broyalegame=game
).annotate(
points=F('rank')
).order_by(
'rank'
)