Problem with group by

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problem with group by

Julio Gorocica

I have some records in the database and I need to group them by the year, the problem is: if the day or month changes then django isn't grouping them.

This is my queryset:

classifications = ClassificationDocument.objects.filter(Q(area=request_area) and Q(classification__is_active=True)) \
.annotate(year=ExtractYear('created')) \
.only('documents', 'title', 'code', 'year')

it's there any solution for this?

Thanks to everyone .

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit