class GeoManager
The GeoManager
is required in order to use the legacy GeoQuerySet Methods.
Deprecated since version 1.9: All GeoQuerySet
methods have been deprecated and replaced by equivalent database functions. As soon as the legacy methods have been replaced in your code, you should be able to remove the special GeoManager
from your GIS-enabled classes.
In older versions, the manager was required to conduct geographic queries. Without it, all geographic filters failed.
GeoManager
was required even if the model did not have a geographic field itself, e.g., in the case of a ForeignKey
relation to a model with a geographic field. For example, if we had an Address
model with a ForeignKey
to our Zipcode
model:
from django.contrib.gis.db import models class Address(models.Model): num = models.IntegerField() street = models.CharField(max_length=100) city = models.CharField(max_length=100) state = models.CharField(max_length=2) zipcode = models.ForeignKey(Zipcode, on_delete=models.CASCADE) objects = models.GeoManager()
The geographic manager was needed to do spatial queries on related Zipcode
objects, for example:
qs = Address.objects.filter(zipcode__poly__contains='POINT(-104.590948 38.319914)')
Please login to continue.