Skip to content

Commit

Permalink
Allow send empty string on not required in custom contribution API
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Jul 2, 2024
1 parent 94b8e5b commit 83a00c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion georiviere/portal/serializers/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,11 @@ def __init__(self, *args, **kwargs):
output_field = serializers.DateTimeField
required = key in schema.get("required", [])
# make field required or not
kwargs = {"label": field.get("title"), "required": required}
if output_field == serializers.CharField:
kwargs["allow_blank"] = not required
self.fields[key] = output_field(
label=field.get("title"), required=required, allow_blank=not required
**kwargs
)

# station is required if defined at custom_type level. Geom is not required because replace by station geom
Expand Down

0 comments on commit 83a00c9

Please sign in to comment.