1👍
✅
You should not use dateajout
, that is still the datetime
, you use date
, the thing you annotated:
items = (
Anomalie.objects.annotate(date=TruncDate('dateajout'))
.values('date')
.annotate(count=Count('id'))
.values('date', 'count')
)
You can simplify this to:
items = Anomalie.objects.values(date=TruncDate('dateajout')).annotate(
count=Count('id')
).order_by('date')
Source:stackexchange.com