From 4c358df66a1c808dce09c9da634bb50969d18c37 Mon Sep 17 00:00:00 2001 From: Guillaume Pannatier Date: Thu, 29 May 2014 08:53:25 +0200 Subject: [PATCH] [1.6.x] Fixed #22710 -- Documented aggregation behavior for empty QuerySets. Thanks matklad for the report. Backport of 7c6e96ec1f from master --- docs/ref/models/querysets.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index dbca6b58060..1344c6744b6 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2487,6 +2487,12 @@ aggregate functions, see aggregation on date/time fields in SQLite will raise ``NotImplementedError``. +.. admonition:: Note + + Aggregation functions will return ``None`` when used with an empty + ``QuerySet``. For example, the ``Count`` aggregation function will return + ``None`` instead of ``0`` if the ``QuerySet`` contains no entries. + Avg ~~~