Complete the code to import the ModelSerializer class from Django REST framework.
from rest_framework.serializers import [1]
The ModelSerializer class is imported from rest_framework.serializers to create serializers based on Django models.
Complete the code to define a serializer class for a Django model named Book.
class BookSerializer([1]): class Meta: model = Book fields = '__all__'
The serializer class should inherit from ModelSerializer to automatically handle model fields.
Fix the error in the serializer Meta class to correctly specify the model.
class AuthorSerializer(ModelSerializer): class Meta: model = [1] fields = ['id', 'name', 'email']
The model attribute must be set to the actual Django model class, which is Author here.
Fill both blanks to create a serializer that only includes the 'title' and 'author' fields from the Book model.
class BookSerializer(ModelSerializer): class Meta: model = [1] fields = [[2]]
The serializer should specify the Book model and include only the 'title' and 'author' fields.
Fill all three blanks to create a serializer that excludes the 'created_at' and 'updated_at' fields from the Article model.
class ArticleSerializer(ModelSerializer): class Meta: model = [1] exclude = [[2]] fields = [3]
The serializer uses the Article model, excludes the 'created_at' and 'updated_at' fields, and sets fields = None to allow exclusion.