On Wed, Feb 24, 2010 at 1:01 AM, Manolis <msta...@gmail.com> wrote: > Hello, > I have a model like this: > class Report(models.Model): > date_submitted = models.DateTimeField() > > I want to calculate some aggregate counts per month. The SQL query for > this would be: > SELECT YEAR(date_submitted), MONTH(date_submitted), count(id) > FROM Report > GROUP BY YEAR(date_submitted), MONTH(date_submitted) > > Is it possible to get my counts with the aggregation API of Django 1.1 > without resorting to database-dependent code?
At present, not really. It is possible using extra(), but not as a core feature of the aggregation APIs. > If no, is this functionality supported by some later version of the > aggregation API or planned for some future release? It's planned in the "we will accept a patch that does this" sense. Ticket #10302 is tracking the idea; it describes the .extra() workaround. http://code.djangoproject.com/ticket/10302 Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.