From af83df91d2c6570a48a823d2860622ae450b6fff Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Tue, 7 Jan 2025 14:55:30 +0100 Subject: [PATCH] bplan/serializer: add binary=True to point JSONField as we receive a string containing (geo)json, not actual json --- docs/bplan_api.md | 6 +++--- meinberlin/apps/bplan/serializers.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/bplan_api.md b/docs/bplan_api.md index fed266a094..a6ff51a18d 100644 --- a/docs/bplan_api.md +++ b/docs/bplan_api.md @@ -101,7 +101,7 @@ The following fields need to be provided: - End date of the participation in - [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) (if no time zone is defined, german time zones UTC+01 and UTC+02 are used) -- *point*: geojson +- *point*: string containing valid geojson - Location of the bplan - Projection: WGS84 / EPSG:4326 - *(diplan only) tile_image*: string @@ -203,7 +203,7 @@ curl \ "office_worker_email": "test@example.com", "start_date": "2019-01-01T00:00", "end_date": "2022-01-01T00:00", - "point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}} + "point": "{\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\", \"coordinates\":[13.411924777644563,52.499598134440944]}}" } ' ``` @@ -224,7 +224,7 @@ curl -X POST http://127.0.0.1:8003/api/organisations/1/bplan/ \ "office_worker_email": "test@example.com", "start_date": "2019-01-01T00:00", "end_date": "2022-01-01T00:00", - "point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}} + "point": "{\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\", \"coordinates\":[13.411924777644563,52.499598134440944]}}" } ' ``` diff --git a/meinberlin/apps/bplan/serializers.py b/meinberlin/apps/bplan/serializers.py index a0359edc21..8a6242d9c3 100644 --- a/meinberlin/apps/bplan/serializers.py +++ b/meinberlin/apps/bplan/serializers.py @@ -83,7 +83,7 @@ class BplanSerializer(serializers.ModelSerializer): ) # overwrite the point model field so it's expecting json, the original field is validated as a string and therefore # doesn't pass validation when not receiving a string - point = serializers.JSONField(required=False, write_only=True) + point = serializers.JSONField(required=False, write_only=True, binary=True) class Meta: model = Bplan