Complete the code to import the serializer base class.
from rest_framework import [1]
The serializers module from rest_framework provides the base classes to create serializers.
Complete the serializer class definition to inherit from the correct base class.
class UserSerializer([1].Serializer): pass
Serializer classes must inherit from serializers.Serializer to define how data is converted.
Fix the error in the serializer field declaration.
class ProductSerializer(serializers.Serializer): name = serializers.[1]Field(max_length=100)
The CharField is used for text fields like product names.
Fill both blanks to create a serializer that automatically maps model fields.
class BookSerializer(serializers.[1]): class Meta: model = Book fields = [2]
ModelSerializer automatically maps model fields. Using '__all__' includes all fields.
Fill all three blanks to define a serializer with custom validation.
class CommentSerializer(serializers.Serializer): text = serializers.CharField(max_length=200) def validate_[1](self, value): if '[2]' in value.lower(): raise serializers.ValidationError('[3]') return value
The method validate_text validates the text field. It checks if the word 'spam' is in the text and raises an error message.