Reference QuerySet API reference QuerySet APIAggregation functions
An optional Q object that’s used to filter the rows that are aggregated. See Conditional aggregation and Filtering on annotations for example usage.
743 sections in Django 6.0 Search all versions →
Reference QuerySet API reference QuerySet APIAggregation functions
An optional Q object that’s used to filter the rows that are aggregated. See Conditional aggregation and Filtering on annotations for example usage.
Reference QuerySet API reference QuerySet APIAggregation functions
Keyword arguments that can provide extra context for the SQL generated by the aggregate.
Reference QuerySet API reference QuerySet APIAggregation functions
classCount(expression,distinct=False,filter=None,**extra)[source] : Returns the number of objects that are related through the provided expression. Count('*') is equivalent to the SQL COUNT(*) expression.
Reference QuerySet API reference
This section provides reference material for query-related tools not documented elsewhere.
Reference QuerySet API reference Query-related tools
classQ[source] A Q() object represents an SQL condition that can be used in database-related operations. It’s similar to how an F() object represents the value of a model field or annotation. They make it possible to define and reuse conditions.
Reference GIS QuerySet API Reference
The spatial lookups in this section are available for GeometryField and RasterField. For an introduction, see the spatial lookups introduction. For an overview of what lookups are compatible with a particular spatial backend, refer to the spatial lookup compatibility table.
Reference GIS QuerySet API Reference Spatial Lookups
All examples in the reference below are given for geometry fields and inputs, but the lookups can be used the same way with rasters on both sides.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, MariaDB, MySQL, SpatiaLite, PGRaster (Native) Tests if the geometry or raster field’s bounding box completely contains the lookup geometry’s bounding box.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, MariaDB, MySQL, SpatiaLite, PGRaster (Native) Tests if the geometry field’s bounding box overlaps the lookup geometry’s bounding box.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, MariaDB, MySQL, SpatiaLite, PGRaster (Native) Tests if the geometry field’s bounding box is completely contained by the lookup geometry’s bounding box.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Bilateral) Tests if the geometry field spatially contains the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, PGRaster (Bilateral) Returns true if the lookup geometry intersects the interior of the geometry field, but not the boundary (or exterior).
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, PGRaster (Bilateral), SpatiaLite Tests if no point in the geometry field is outside the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MySQL, PGRaster (Bilateral), SpatiaLite Tests if no point in the lookup geometry is outside the geometry field.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, MariaDB, MySQL, SpatiaLite, PGRaster (Conversion) Tests if the geometry field spatially crosses the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Bilateral) Tests if the geometry field is spatially disjoint from the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Conversion) Tests if the geometry field is spatially equal to the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Bilateral) Tests if the geometry field is “equal” to the lookup geometry. On Oracle, MySQL, and SpatiaLite, it tests spatial equality, while on PostGIS it tests equality of bounding boxes.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS, Oracle, MariaDB, MySQL, SpatiaLite, PGRaster (Bilateral) Tests if the geometry field spatially intersects the lookup geometry.
Reference GIS QuerySet API Reference Spatial Lookups
Availability: PostGIS Tests if the geometry is empty. Example: