I'm making a game site using django and I want to do a ranking based on the score of all users! For now it looks like this:
views.py :
def index(request):
perfis = Perfil.objects.all().order_by('-pontuacao_ultima')
return render(request, 'index.html', {'perfis' : perfis})
index.html :
{% for perfis in perfis %}
<tr>
<td>1</td>
<td>{{ perfis.nome }}</td>
<td>{{ perfis.pontuacao_ultima }} pontos</td>
</tr>
{% endfor %}
In case he is already ordering, however I am doubtful what to do for the position number to vary according to the actual position of the player (first, second, etc.). For now it is showing only the 1 (I put it manually in the html).