【发布时间】:2013-10-20 16:21:53
【问题描述】:
如果您查看 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
这个额外的关键字参数是做什么用的?我可以使用它们对聚合进行更复杂的查询吗?我试图在上面找到任何文档,但没有成功。我相信它没有记录在案,但无论如何,这些额外的论点是什么,可以用它们做什么?
谢谢。
【问题讨论】:
标签: python django orm aggregate-functions django-orm