From 0e446dc868cc43c255b1636acd3dff1ea4e06004 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Tue, 5 Mar 2024 07:56:05 +0200 Subject: [PATCH] Fix test at `test_geometry_serializer_method_field_nogeo` (#2) The function `add_to_fields` does not have any checks for `None` and since the app now supports `geo_field = None` it adds it to the fields of the serializer. In any case, adding an `assert` in the `add_to_fields` function would have made the error obvious in the first place. --- rest_framework_gis/serializers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework_gis/serializers.py b/rest_framework_gis/serializers.py index 4b270fb0..1b808e44 100644 --- a/rest_framework_gis/serializers.py +++ b/rest_framework_gis/serializers.py @@ -96,7 +96,9 @@ def add_to_fields(field_name): meta.fields += additional_fields check_excludes(meta.geo_field, 'geo_field') - add_to_fields(meta.geo_field) + + if meta.geo_field is not None: + add_to_fields(meta.geo_field) meta.bbox_geo_field = getattr(meta, 'bbox_geo_field', None) if meta.bbox_geo_field: