[Answered ]-Django, how to group by day

2👍

I don’t think the __day mechanism used with filters (field__day) works with values. If your database has a function to extract the day from your date field you can do something like the snippet shown below.

Match.objects.filter(sendDate__gte=dateToStats).extra(
    select = {"sendDate__day": "extract (day from sendDate)"})

Extract (day from sendDate) is specific to Postgresql. You will have to replace it with your database’s equivalent.

Leave a comment