We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b48e336 commit 4e9074bCopy full SHA for 4e9074b
backend/core/views.py
@@ -1089,8 +1089,14 @@ def create(self, validated_data):
1089
1090
def to_representation(self, instance):
1091
ret = super().to_representation(instance)
1092
- if self.context.get("request") and self.context["request"].method == "GET":
+ request = self.context.get("request")
1093
+ if request and request.method == "GET":
1094
ret["user"] = UserSerializer(instance.user).data
1095
+ centroid_param = request.query_params.get("centroid", "false").lower()
1096
+ if centroid_param == "true":
1097
+ centroid = instance.geom.centroid
1098
+ centroid.srid = instance.geom.srid
1099
+ ret["geom"] = GeometryField().to_representation(centroid)
1100
return ret
1101
1102
0 commit comments