I need to retrieve month name with sum total price of the corresponding month. Here is my order table sample
My try is:
month_wise_sales = Order.objects\
.annotate(month=ExtractMonth('created_at'))\
.values('month')\
.annotate(total_sales=Sum('total_price'))
It will return
<QuerySet [{'month': 7, 'total_sales': Decimal('138400.00')}, {'month': 9, 'total_sales': Decimal('1150.00')}]>
My desire is something like this
[{'month': July, 'total_sales': Decimal('138400.00')}, {'month': September, 'total_sales': Decimal('1150.00')}]
How to resolve this?