diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 13 | ||||
| -rw-r--r-- | docs/releases/1.9.txt | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 3dc66f631a..d2cbc63203 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2802,12 +2802,19 @@ by the aggregate. Avg ~~~ -.. class:: Avg(expression, output_field=None, **extra) +.. class:: Avg(expression, output_field=FloatField(), **extra) - Returns the mean value of the given expression, which must be numeric. + Returns the mean value of the given expression, which must be numeric + unless you specify a different ``output_field``. * Default alias: ``<field>__avg`` - * Return type: ``float`` + * Return type: ``float`` (or the type of whatever ``output_field`` is + specified) + + .. versionchanged:: 1.9 + + The ``output_field`` parameter was added to allow aggregating over + non-numeric columns, such as ``DurationField``. Count ~~~~~ diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 525cf34630..21df59f051 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -200,6 +200,10 @@ Models (such as :lookup:`exact`, :lookup:`gt`, :lookup:`lt`, etc.). For example: ``Entry.objects.filter(pub_date__month__gt=6)``. +* You can specify the ``output_field`` parameter of the + :class:`~django.db.models.Avg` aggregate in order to aggregate over + non-numeric columns, such as ``DurationField``. + CSRF ^^^^ |
