1

I am trying to GROUP BY with Django ORM:

sub = (
        Participant.objects
        .values('category')
        .annotate(
            average=Avg(F('price')),
        )
    )

It works as expected BUT the queryset does not contains instances of the model anymore. If contains dicts because values() has been called.

How can do a group by query and get a regular queryset (with model instances)?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
znat
  • 13,144
  • 17
  • 71
  • 106

0 Answers0