django, get an object from a list of filtered objects which has the maximum value for a field
'objs=Modelname.objects.filter(student__in=malerep).order_by('-Votes','-student__Percentage')'
then using objs[0] i was able to access the object of the student with max votes and max percentage in case of a tie.
Modelname.objects.filter(student__in=malerep).order_by('-Votes','-student__Percentage')
Here i want to specifically get the student who has the maximum number of votes.
What i am trying to do is, to get the list of students who stood for an election and got some votes and then sort them based on the number of votes they got. Now if i can access the first object in this list , i can make necessary modifications for the student in the database who won the election and also get the details of the rest.
I am stuck at this point. Please help
Thanx in advance.