My django code is broken and raises the following AttributeError
:
AttributeError: 'GeoQuerySet' object has no attribute 'extent'
In my code I try to call extent on a django geoqueryset
:
if raster and bbox:
self.extent = qs.extent()
My Django version is currently 1.10 and has recently been upgraded from Django 1.9.
答案 0 :(得分:4)
This is because Django deprecated the extent
method on GeoQuerySet
s since Django version 1.8. This can be fixed using the Extent
Aggregate Function like so:
from django.contrib.gis.db.models import Extent
# ...
if raster and bbox:
self.extent = qs.aggregate(Extent('geometry')).get(
'geometry__extent')