4👍
✅
You should add a .order_by(…)
clause [Django-doc] to force a GROUP BY
on the fields listed in the .order_by(…)
, so:
Deviation.objects.values('day_of_calculation').annotate(
deviation_numbers=ArrayAgg('deviation_number')
).order_by('day_of_calculation')
Source:stackexchange.com