You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model with a geom (srid=3035) and I want to serialize it as geom (srid=4326).
Did not found a solution to do this with django-restframework-gis?
My approach was:
from django.contrib.gis.db.models.functions import Transform
class TransformManager(models.Manager):
def get_queryset(self):
return super().get_queryset().annotate(geom_4326=Transform("geom", 4326))
class State(models.Model):
id = models.BigIntegerField(primary_key=True)
name = models.CharField(max_length=60)
geom = models.MultiPolygonField(srid=3035)
objects = TransformManager()
class StatesSerializer(GeoFeatureModelSerializer):
class Meta:
model = State
geo_field = "geom_4326"
fields = [
"id",
"name",
"geom_4326"
]
class StatesListAPIView(ListAPIView):
queryset = State.objects.all()
serializer_class = StatesSerializer
lookup_field = 'id'
but this gives me: django.core.exceptions.ImproperlyConfigured: Field name geom_4326is not valid for modelState.
I have a model with a geom (srid=3035) and I want to serialize it as geom (srid=4326).
Did not found a solution to do this with django-restframework-gis?
My approach was:
but this gives me:
django.core.exceptions.ImproperlyConfigured: Field name
geom_4326is not valid for model
State.
Also found this:
https://stackoverflow.com/questions/22449406/how-to-transform-geometry-in-django-rest-framework-gis/22537247#22537247
But couldn't get it to work... (see my comment on that answer)
Any help? thx
The text was updated successfully, but these errors were encountered: