POSTing data in GeoJSON format

125 views
Skip to first unread message

Aris Almpanis

unread,
Sep 7, 2019, 2:27:07 PM9/7/19
to Django REST Framework GIS
Hello guys,

I am pretty new using the framework (both rest and gis rest) so indulge me for any "obvious" answers to my question!

Ok, here it goes:

Does the framework support out-of-the-box deserilization of GeoJSON input when using GeoFeatureModelSerializer ?

I used the above model seriliazer succesfully when responding to GET requests of my models but when I tried the other way around I am getting error responses like: some model attribute is required.

To make matters easier for anybody that can answer this - this is my use case / setup:

My model:

class Field(models.Model):
    name = models.CharField(max_length=20)

    location = gis_models.MultiPolygonField(srid=4326, null=True, blank=True)

    perimeter = models.FloatField(null=True, blank=True)
    area = models.FloatField(null=True, blank=True)
    aspect = models.CharField(max_length=20, null=True, blank=True)
    altitude = models.FloatField(max_length=20, null=True, blank=True)

The serializer:

class FieldSerializer(GeoFeatureModelSerializer):

    class Meta:
        model = Field
        geo_field = "location"
        fields = "__all__

When trying to POST using payload the response I receive from GET (without the ids) I am getting an error: "name" is required.

Thanks a lot in advance. If I skipped any crucial info let me know!

Reply all
Reply to author
Forward
0 new messages