perf: 修改PostgreSQL数据库参数为必填

pull/9595/head
jiangweidong 2023-02-16 17:27:40 +08:00 committed by Jiangjie.Bai
parent 9af8c629ca
commit 3b3355f3f8
1 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,8 @@ class DatabaseSerializer(AssetSerializer):
def validate(self, attrs):
platform = attrs.get('platform')
if platform and getattr(platform, 'type') == 'mongodb' \
db_type_required = ('mongodb', 'postgresql')
if platform and getattr(platform, 'type') in db_type_required \
and not attrs.get('db_name'):
raise ValidationError({'db_name': _('This field is required.')})
return attrs