在 Django 中聚合后这是什么?

What's this after aggregation in django?

我从 Django 项目中看到以下代码。我理解是聚合,但是聚合后的['kw__sum']是什么?

Project.objects.filter(project = project).aggregate(Sum('kw'))['kw__sum']

谢谢

在这里,如果你查看 examples you will see that aggregate returns 字典,那么最后一部分只是字典查找

aggregation = Project.objects.filter(project = project).aggregate(Sum('kw'))
result = aggregation['kw__sum']

来自文档

Returns a dictionary of aggregate values (averages, sums, etc.) calculated over the QuerySet. Each argument to aggregate() specifies a value that will be included in the dictionary that is returned.