Alex Rivera | Logout

Django - Group By with Date part alone

Asked 2011-03-10T08:30:32.207
9
MyModel.objects.filter(created_at__gte='2011-03-09', created_at__lte='2011-03-11').values('created_at','status').annotate(status_count=Count('status'))

The above query has the problem with the created_at datetime field. Is it possible to tune the above query to ignore the time value and use the date value alone while performing group by?

Edit
Report

1 Answer

6

I'm too late for this question, but for future reference, I want to point out that this is actually possible with native Django, as described at https://stackoverflow.com/a/2283913

answered 2012-05-07T17:55:40.227

Your Answer