Browse Source

fix: 修复post方法调用AuthBook接口时500的问题

pull/8465/head
Jiangjie.Bai 2 years ago committed by Jiangjie.Bai
parent
commit
5ed65ca2ff
  1. 10
      apps/assets/serializers/account.py

10
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):

Loading…
Cancel
Save