如何显示基于Django模板中的字段值的排名?

时间:2018-12-25 05:23:34

标签: django python-3.x django-models django-templates

我有一个包含总分的详细信息列表。我想显示基于总得分的排名。如果分数相等,则等级必须相同。怎么做? 预先感谢。

{% for rank in ranking %}
                                      {% with forloop.counter as count %}
                                          <tr>
                                              <td>{% if rank.name  %} {{rank.name}} {% endif %}</td>
                                              <td>{{count}}</td> 
                                              <td>{% if rank.total_score %}{{rank.total_score}}%{% else %} {% trans '0%' %}{% endif %}</td>
                                          </tr>
                                      {% endwith %}
                              {% endfor %}

0 个答案:

没有答案
相关问题