djangodocs.org

743 sections in Django 6.0 Search all versions →

distance_lte

Reference GIS QuerySet API Reference Distance Lookups

Returns models where the distance to the geometry field from the lookup geometry is less than or equal to the given distance value.

dwithin

Reference GIS QuerySet API Reference Distance Lookups

Returns models where the distance to the geometry field from the lookup geometry are within the given distance from one another. Note that you can only provide Distance objects if the targeted geometries are in a projected system.

Aggregate Functions

Reference GIS QuerySet API Reference Distance Lookups

Django provides some GIS-specific aggregate functions. For details on how to use these aggregate functions, see the topic guide on aggregation.

Collect

Reference GIS QuerySet API Reference Distance LookupsAggregate Functions

classCollect(geo_field,filter=None)[source] Availability: PostGIS, MariaDB, MySQL, SpatiaLite Returns a GEOMETRYCOLLECTION or a MULTI geometry object from the geometry column.

filter() and exclude()

Topic guide Aggregation Aggregations and other QuerySet clauses

Aggregates can also participate in filters. Any filter() (or exclude()) applied to normal model fields will have the effect of constraining the objects that are considered for aggregation.

Topic guide Aggregation Aggregations and other QuerySet clausesvalues()

As with the filter() clause, the order in which annotate() and values() clauses are applied to a query is significant. If the values() clause precedes the annotate(), the annotation will be computed using the grouping described by the values() clause.

Aggregating annotations

Topic guide Aggregation Aggregations and other QuerySet clauses

You can also generate an aggregate on the result of an annotation. When you define an aggregate() clause, the aggregates you provide can reference any alias defined as part of an annotate() clause in the query.

QuerySet iteration

Release notes Django 1.6 release notes Backwards incompatible changes in 1.6

The QuerySet iteration was changed to immediately convert all fetched rows to Model objects. In Django 1.5 and earlier the fetched rows were converted to Model objects in chunks of 100.

Release notes Django 1.6 release notes Backwards incompatible changes in 1.6

When the time zone support added in Django 1.4 was active, QuerySet.dates() lookups returned unexpected results, because the aggregation was performed in UTC. To fix this, Django 1.6 introduces a new API, QuerySet.datetimes().