[Solved]-Make group by having count(*) with django orm

25👍

Read the docs about the combination of using values+annotate, this is what you need:

from django.db.models import Count

Reservation.objects.values('day').annotate(cnt=Count('id')).filter(cnt__lte=5)
👤Todor

Leave a comment