Let's say I have a model name Book. I have two views(list and detail)
models.py
class Book(models.Model):
name = models.CharField(max_length=100)
author = models.CharField(max_length=100)
publishdate = models.DateTimeField()
serializers.py
class BookSerializer(serializers.ModelSerializer):
class Meta:
model = Book
If I'm going to use this serializer in my list view and detail view. Can I set the return field? Example : list view only return name list only and detail view will return name, author, publishdate field. Or do I have to create new serializer and insert fields in Class Meta on both class?