在使用 django 的时候发现了一个坑 例如: In [54]: print(F.objects.all().values("age").annotate(fff=Count("age")).query) SELECT "a_f"."age", COUNT("a_f"."age") AS "fff" FROM "a_f" GROUP BY &qu
代码: from django.db.models import Sum alarm_sum_group_items = models.FILE_PROTECT_ALARM.objects.filter(customer_id=customer_id).values('device_hash').annotate(alarm_sum=Sum('cmn_merge_count')) data = [] for item in alarm_sum_group_items: tmp = {} tmp[