我的django代码损坏了,并引发了以下AttributeError
AttributeError: 'GeoQuerySet' object has no attribute 'extent'在我的代码中,我尝试调用django geoqueryset上的扩展
if raster and bbox:
self.extent = qs.extent()我的Django版本目前是1.10,最近从Django 1.9升级。
发布于 2017-07-12 16:03:03
这是因为从Django版本1.8开始,Django就在GeoQuerySet上deprecated了extent方法。可以使用Extent Aggregate Function修复此问题,如下所示:
from django.contrib.gis.db.models import Extent
# ...
if raster and bbox:
self.extent = qs.aggregate(Extent('geometry')).get(
'geometry__extent')https://stackoverflow.com/questions/45051785
复制相似问题