I am making a query that needs to get the max number of votes on one of TODAY’s objects.
I tried max_votes = App.objects.get(day=today).order_by("-votes")[0], but that gave me an attribute error. I don’t get that error when I do max_votes = Day.objects.all().order_by("-votes")[0]
How do I properly get the max number of votes on one of today’s objects?
okay, so get() is supposed to return only one object. get() is designed for fetching by primary key. its going to give you an error if it has multiple objects with the same attribute. what you are probably looking for is filter()
so you can do something like this