I am trying to group products by DAY, however date_created is a datetime field.
Product.objects.values('date_created')
.annotate(available=Count('available_quantity'))
returns:
[
{'date_created': datetime.datetime(2012, 4, 14, 13, 3, 6), 'available': 1},
{'date_created': datetime.datetime(2012, 4, 14, 17, 12, 9), 'available': 1},
...
]
I want:
[
{'date_created': datetime.datetime(2012, 4, 14), 'available': 2}, ...
]
edit: database backend MYSQL
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…