I have a model in a simple django application that records the score for people entering a competition. I have two model objects: Entry and Person. Each record has an identity, and a person has several records.
I want to create a page that shows each user, their total score and their rank.
The command I have received so far is as follows:
Entry.objects.values('person__name').annotate(total=Sum('score')).order_by('-total')
I can get the result of this on the page using the for block. The only thing I do not understand is the rank.
What would be the best way to add a numerical record rank to each record, including the fact that when two points coincide, the rank reflects this (ie "4 =")? Would it be better to try to do this in the template using forblock.counter and some lookahead / behind mechanism, or try to process this field in the request itself?
source
share