如果你看一下Django中聚合函数的定义,你会发现它们实际上是django.db.models.aggregates.Aggregate
子类的类,它们的构造函数如下所示:
class Aggregate(object):
"""
Default Aggregate definition.
"""
def __init__(self, lookup, **extra):
"""Instantiate a new aggregate.
* lookup is the field on which the aggregate operates.
* extra is a dictionary of additional data to provide for the
aggregate definition
Also utilizes the class variables:
* name, the identifier for this aggregate function.
"""
self.lookup = lookup
self.extra = extra
#... the rest is truncated
这个额外的关键字参数用于什么?我可以使用它们使用聚合进行更复杂的查询吗?我试图在其上找到任何文档,但没有成功。我相信它没有记录,但无论如何,这些额外的争论是什么以及可以用它们做些什么?
感谢。
答案 0 :(得分:0)
当然,
只需查看来源extra
is unpacked and passed to the "backend-specific" aggregate class即可。
SQL
后端的后端特定聚合在db.models.sql.aggregates
中找到。