fix: 创建资产失败

pull/12563/head
feng 10 months ago committed by 老广
parent ae68241812
commit e4d8ce097a

@ -397,17 +397,17 @@ class ResourceLabelsMixin(serializers.Serializer):
labels = LabelRelatedField(many=True, label=_('Labels'), required=False, allow_null=True, source='res_labels') labels = LabelRelatedField(many=True, label=_('Labels'), required=False, allow_null=True, source='res_labels')
def update(self, instance, validated_data): def update(self, instance, validated_data):
labels = validated_data.pop('labels', None) labels = validated_data.pop('res_labels', None)
res = super().update(instance, validated_data) res = super().update(instance, validated_data)
if labels is not None: if labels is not None:
instance.labels.set(labels, bulk=False) instance.res_labels.set(labels, bulk=False)
return res return res
def create(self, validated_data): def create(self, validated_data):
labels = validated_data.pop('labels', None) labels = validated_data.pop('res_labels', None)
instance = super().create(validated_data) instance = super().create(validated_data)
if labels is not None: if labels is not None:
instance.labels.set(labels, bulk=False) instance.res_labels.set(labels, bulk=False)
return instance return instance
@classmethod @classmethod

Loading…
Cancel
Save