[Fixed]-Django queryset – classify and filter by value

1👍

You need to group the items by name and get the maximum days_left_to_consumption like this:

from django.db.models import Max
fruits = Fruit.objects.values('name').annotate(max_days_left_to_consumption=Max('days_left_to_consumption'))
👤Ivan

Leave a comment