Adicionar método .update() ao EventSerializer

parent 8c5ac6c1
......@@ -24,12 +24,12 @@ class EventSerializer(serializers.DocumentSerializer):
event.save()
return event
# def update(self, instance, validated_data):
# owners_data = validated_data.pop("owners")
# updated_instance = super(EventSerializer, self).update(instance, validated_data)
def update(self, instance, validated_data):
owners_data = validated_data.pop("owners")
event = super(EventSerializer, self).update(instance, validated_data)
# for owner_data in owners_data:
# updated_instance.owner_data.append(UserRef(**owner_data))
for owner_data in owners_data:
event.owners.append(UserRef(**owner_data))
# updated_instance.save()
# return updated_instance
event.save()
return event
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment