Skip to content

Commit

Permalink
Fix test at test_geometry_serializer_method_field_nogeo (#2)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
suricactus authored Mar 5, 2024
1 parent bb342c7 commit 0e446dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rest_framework_gis/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0e446dc

Please sign in to comment.