fix: 修复导入更新资产时包含labels报错的问题(取消id唯一键校验)

pull/9456/head
Bai 2 years ago committed by Jiangjie.Bai
parent 90d5f62327
commit b41d30dbac

@ -133,7 +133,8 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet):
def create(self, request, *args, **kwargs):
if request.path.find('/api/v1/assets/assets/') > -1:
return Response({'error': _('Cannot create asset directly, you should create a host or other')}, status=400)
error = _('Cannot create asset directly, you should create a host or other')
return Response({'error': error}, status=400)
return super().create(request, *args, **kwargs)

@ -34,8 +34,10 @@ class AssetLabelSerializer(serializers.ModelSerializer):
model = Label
fields = ['id', 'name', 'value']
extra_kwargs = {
# 取消默认唯一键的校验
'id': {'validators': []},
'name': {'required': False},
'value': {'required': False}
'value': {'required': False},
}

Loading…
Cancel
Save