Reputation: 341
I have two dates.
start_date = '2015/01/01'
end_date = '2015/04/01'
My query return all orders between this two dates, but i need group by month.
So:
data1: 2015/01/01 #start_date
data2: 2015/02/01
data3: 2015/03/01
data4: 2015/04/01 #end_date
I need to chart with this data.
Upvotes: 0
Views: 215
Reputation: 8326
You could try itertools.groupby
, but careful as Django might cache the generator as a list and consume it.
from itertools import groupby
groupby(orders, lambda order : order.date.month)
Upvotes: 1