to learn django I did a small app that let the user vote for the restaurant of their choice.
my table hold who voted for an option, and I am trying to query a table base on a date, and then get the one that most attribute is repeated. to know the restaurant that won.
and I would like to query base on a date(that way they can vote for some one different each day), and then get the restaurant_id that is most repeated.
Image of the table
link to image
https://www.dropbox.com/s/pszt46bdqstahky/table.png?dl=0
this is my code.
getting the queryset of dates. but from there how do I get the most repetead restaurant_id?
the_max = Choice.objects.filter(date_vote=date)
the_max = list(the_max)
d = {x: the_max(x) for x in the_max}
chosen_restaurant = max(d, key=d.get)
I was trying to put the repetition into a dictionary and the get the max from there. does django have another filter to do aggregation? with a little explanation how to use it?
thanks guys.