summaryrefslogtreecommitdiff
path: root/docs/ref/models/querysets.txt
diff options
context:
space:
mode:
authorTom <tom@tomforb.es>2017-04-22 16:44:51 +0100
committerTim Graham <timograham@gmail.com>2017-08-12 17:58:28 -0400
commitb78d100fa62cd4fbbc70f2bae77c192cb36c1ccd (patch)
treebe1f272298c15c6a261e33dff7486b0c3727b407 /docs/ref/models/querysets.txt
parent489421b01562494ab506de5d30ea97d7b6b5df30 (diff)
Fixed #27849 -- Added filtering support to aggregates.
Diffstat (limited to 'docs/ref/models/querysets.txt')
-rw-r--r--docs/ref/models/querysets.txt25
1 files changed, 18 insertions, 7 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 74f83ab8c5..9c329d48ee 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -3085,6 +3085,17 @@ of the return value
``output_field`` if all fields are of the same type. Otherwise, you
must provide the ``output_field`` yourself.
+``filter``
+~~~~~~~~~~
+
+.. versionadded:: 2.0
+
+An optional :class:`Q object <django.db.models.Q>` that's used to filter the
+rows that are aggregated.
+
+See :ref:`conditional-aggregation` and :ref:`filtering-on-annotations` for
+example usage.
+
``**extra``
~~~~~~~~~~~
@@ -3094,7 +3105,7 @@ by the aggregate.
``Avg``
~~~~~~~
-.. class:: Avg(expression, output_field=FloatField(), **extra)
+.. class:: Avg(expression, output_field=FloatField(), filter=None, **extra)
Returns the mean value of the given expression, which must be numeric
unless you specify a different ``output_field``.
@@ -3106,7 +3117,7 @@ by the aggregate.
``Count``
~~~~~~~~~
-.. class:: Count(expression, distinct=False, **extra)
+.. class:: Count(expression, distinct=False, filter=None, **extra)
Returns the number of objects that are related through the provided
expression.
@@ -3125,7 +3136,7 @@ by the aggregate.
``Max``
~~~~~~~
-.. class:: Max(expression, output_field=None, **extra)
+.. class:: Max(expression, output_field=None, filter=None, **extra)
Returns the maximum value of the given expression.
@@ -3135,7 +3146,7 @@ by the aggregate.
``Min``
~~~~~~~
-.. class:: Min(expression, output_field=None, **extra)
+.. class:: Min(expression, output_field=None, filter=None, **extra)
Returns the minimum value of the given expression.
@@ -3145,7 +3156,7 @@ by the aggregate.
``StdDev``
~~~~~~~~~~
-.. class:: StdDev(expression, sample=False, **extra)
+.. class:: StdDev(expression, sample=False, filter=None, **extra)
Returns the standard deviation of the data in the provided expression.
@@ -3169,7 +3180,7 @@ by the aggregate.
``Sum``
~~~~~~~
-.. class:: Sum(expression, output_field=None, **extra)
+.. class:: Sum(expression, output_field=None, filter=None, **extra)
Computes the sum of all values of the given expression.
@@ -3179,7 +3190,7 @@ by the aggregate.
``Variance``
~~~~~~~~~~~~
-.. class:: Variance(expression, sample=False, **extra)
+.. class:: Variance(expression, sample=False, filter=None, **extra)
Returns the variance of the data in the provided expression.