Answers for "group dates by month in django"

1

django group by date from datetime field

Transaction.objects.values('created_at__date').annotate(count=Count('id')).values('created_at__date', 'count').order_by('created_at__date')
Posted by: Guest on May-28-2021
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

Python Answers by Framework

Browse Popular Code Answers by Language