How to pass extra context to Django Rest Framework serializers
问题 It is my first project using Django rest framework and i'm struggling to get this right. I know that in mainstream Django framework, if i need to add extra contexts to a class-based view, i will do something like this: class PostDetail(DetailView): model = Post def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # Add in a QuerySet of all the books by a certain author John context['john_books'] = Book.objects.filter(author=john) return context then, i will be