[Django]-How to transform geometry in django rest framework gis

3👍

Solved:

Add the srid argument to transform function. I was considering as

transform(srid)

first argument as srid but should be like this

transform(srid=3857)

class MyModelViewSet(viewsets.ModelViewSet):

    queryset = MyModel.objects.all().transform(srid=3857)
    serializer_class = MyModelSerializer

2👍

You can provide a default SRID to your GeometryField

geometry = models.GeometryField(srid=3857, null=True, blank=True)

And Django will automatically handle the conversion. More details on the doc and tutorial.

Where can i get queries sample or comprehensive tutorial for rest framework gis?

You can find all about geodjango on Django documentation. Django rest framework is noting but Django.

Leave a comment