Answers for "django orm group by month and year"

0

django orm group by month and year

print([v for v in
       Request.objects.annotate(month=ExtractMonth('date_creation'),
                                year=ExtractYear('date_creation'),)
                      .order_by()
                      .values('month', 'year')
                      .annotate(total=Count('*'))
                      .values('month', 'year', 'total')
       ])
Posted by: Guest on May-24-2021

Code answers related to "django orm group by month and year"

Python Answers by Framework

Browse Popular Code Answers by Language