From 78d8e410db156bc29170da2599b399ec7ba61ccd Mon Sep 17 00:00:00 2001 From: Huiser WANG Date: Sat, 22 Jul 2023 14:04:21 +0800 Subject: [PATCH] fix a latent bug when field_type belongs to int, bool and list. --- apps/common/serializers/dynamic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/common/serializers/dynamic.py b/apps/common/serializers/dynamic.py index a42529b5a..4442fd139 100644 --- a/apps/common/serializers/dynamic.py +++ b/apps/common/serializers/dynamic.py @@ -62,6 +62,8 @@ def create_serializer_class(serializer_name, fields_info): data['required'] = False data = set_default_by_type(field_type, data, field_info) data = set_default_if_need(data, i) + if field_type in ['int', 'bool', 'list'] and "allow_blank" in data.keys(): + data.pop('allow_blank') field_name = data.pop('name') field_class = type_field_map.get(field_type, serializers.CharField) serializer_fields[field_name] = field_class(**data)