我正在尝试使用 django rest 框架获取 GeoJSON 响应,但面临问题
argument of type 'NoneType' is not iterable
这是我的代码
class NewPark(models.Model):
name = models.CharField(max_length=256)
geometry = models.GeometryField(srid=3857, null=True, blank=True)
objects = models.GeoManager()
class Meta:
db_table = u'new_park'
def __unicode__(self):
return '%s' % self.name
class NewParkSerializer(GeoFeatureModelSerializer):
class Meta:
model = NewPark
geo_field = "geometry"
fields = ('id', 'name', 'geometry')
class NewParkViewSet(viewsets.ModelViewSet):
def get_queryset(self):
queryset = NewPark.objects.all()
return queryset
当我将序列化类型更改为“erializers.GeoModelSerializer”时,它正在工作,但我想要 GEOJSON 响应
我搜索了 GeoFeatureModelSerializer 但找不到任何示例geo_field = "geometry"。所有示例都是关于 geo_field = "point"
请帮我解决这个问题?