How to use group by in the django
python의 datetime을 field로 가지는 데이타들을 날짜순(YYYY-MM-DD)으로 정렬하자.
Approach 1
Room.objects.using('op-replica').values('step__code').annotate(cnt=Count('id')).order_by('step__code')
Approach 2
User.objects.all().extra({"day": "date(created_datetime)"}).values("day").annotate(count=Count("id")).order_by('day')