Tercer articulo
Aggregation functions¶
Django provides the following aggregation functions in the django.db.models module. For details on how to use these aggregate functions, see the topic guide on aggregation. See the Aggregate documentation to learn how to create your aggregates.
Warning
SQLite can’t handle aggregation on date/time fields out of the box. This is because there are no native date/time fields in SQLite and Django currently emulates these features using a text field. Attempts to use aggregation on date/time fields in SQLite will raise NotSupportedError.
Empty querysets or groups
Aggregation functions return None when used with an empty QuerySet or group. For example, the Sum aggregation function returns None instead of 0 if the QuerySet contains no entries or for any empty group in a non-empty QuerySet. To return another value instead, define the default argument. Count is an exception to this behavior; it returns 0 if the QuerySet is empty since Count does not support the default argument.