| 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 | |