python - Divides dates in day, month, week Django -
i need generate chart of orders closed day , month. generate average, total sum, etc. need split data period between 2 dates. start date = '01/01/2015' end_date = '01/04/2015' need generate data: so
exemple:
2015/01/01 total sum: 100, average: 10
2015/02/01 total sum: 500, average:50
2015/03/01 total sum: 40, average:2
2015/04/01 total sum: 40, average:2
but in django, queryset return total between 2 dates
filter_params = self.request.get context['orders_confirmed'] = bid.objects.filter(date_confirmed__gte=filter_params.get('summary_date')) context['orders_confirmed'] = context['orders_confirmed'].filter(date_confirmed__lte=filter_params.get('final_summary_date'))
it shows me total, exemple 1500, how divide data?
use timedelta time intervals.
e.g.- first_time = datetime.now() or in case first_time = filter_params.get('summary_date')
second_time = first_time + timedelta(days=30)
. . .
end_time = filter_params.get('finally_summary_date')
run second filter query on desired time intervals.