File size: 527 Bytes
fe9d3dc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from rest_framework import serializers
class ItemSerializer(serializers.Serializer):
url = serializers.URLField(max_length=200)
def create(self, validated_data):
# Typically, you would save the data to a database here.
# As you're not using a database for this instance, you can just return the validated data.
return validated_data
def update(self, instance, validated_data):
instance.url = validated_data.get('url', instance.url)
instance.save()
return instance
|