I am using the following query to get a sum per day:
orders = OrderM.objects.filter(user=request.user) \
.annotate(day=TruncDay('datetime_added')) \
.values('day') \
.annotate(sum=Sum(F('orderd__good_count'))) \
.order_by('-day')
as expected each day changes at 00:00 midnight! I want to change this behaviour so that the sum to be generated on periods from 06:00 to 06:00 of each day. I think that the use of datetime__range = ..
will do, but I'm not experienced in django queries.
Thanks...