diff --git a/apps/assets/serializers/account.py b/apps/assets/serializers/account.py index 5cbb26d88..e4e320f33 100644 --- a/apps/assets/serializers/account.py +++ b/apps/assets/serializers/account.py @@ -53,7 +53,15 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer): return attrs def get_protocols(self, v): - return v.protocols.replace(' ', ', ') + """ protocols 是 queryset 中返回的,Post 创建成功后返回序列化时没有这个字段 """ + if hasattr(v, 'protocols'): + protocols = v.protocols + elif hasattr(v, 'asset') and v.asset: + protocols = v.asset.protocols + else: + protocols = '' + protocols = protocols.replace(' ', ', ') + return protocols @classmethod def setup_eager_loading(cls, queryset):