diff --git a/docs/changelog.rst b/docs/changelog.rst index 228e22b396..2c2bfee0d6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -7,7 +7,11 @@ CHANGELOG **Improvements** -- Allow use of Annotation Categories on annotations other than Points (#4032)" +- Allow use of Annotation Categories on annotations other than Points (#4032) + +**Bug fixes** + +- Fix APIv2 exception on HD Views without Annotations (#4032) **Documentation** diff --git a/geotrek/api/v2/serializers.py b/geotrek/api/v2/serializers.py index 501b8faede..d831bf01f4 100644 --- a/geotrek/api/v2/serializers.py +++ b/geotrek/api/v2/serializers.py @@ -403,7 +403,7 @@ def get_poi(self, obj): def get_annotations(self, obj): annotations = obj.annotations annotations_categories = obj.annotations_categories - for feature in annotations["features"]: + for feature in annotations.get("features", []): feat_id = feature["properties"]["annotationId"] feat_type = feature["geometry"]["type"] if feat_type == "Point" and str(feat_id) in annotations_categories.keys():