[Django]-Django-rest-framework-gis related field

1👍

I found this this morning, and it also applies to DRF-gis:

Django Rest Framework – Get related model field in serializer

I created a serializer on EventLocation and defined it as ‘location’ in EventSerializer and the point is output as a geojson geometry.

1👍

I’m doing something similar, but with MultiPolygon instead of Point. Here’s my serializer:

class AreaSerializer(gis_serializers.GeoFeatureModelSerializer):

    class Meta:
        model = Area
        geo_field = "geom"

Perhaps there isn’t the need to reference the model in geo_field, instead just stating the field directly?

Here’s the repo for my Serializer, if that might help:

https://github.com/kelvinn/alerted-us-web/blob/master/apps/alertdb/serializers.py

Leave a comment