From 7c6e96ec1f99289740132135895be83776cc9ca5 Mon Sep 17 00:00:00 2001 From: Guillaume Pannatier Date: Thu, 29 May 2014 08:53:25 +0200 Subject: [PATCH] Fixed #22710 -- Documented aggregation behavior for empty QuerySets. Thanks matklad for the report. --- 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 d47f8d3a7f..0328295c9b 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2631,6 +2631,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 ~~~