I am using Django REST Framework to create an API for my web app. I have a class \'Comment\', that has depth=2
set in the Meta
class. This works gr
You can set different serializers by overriding the get_serializer_class()
function, like so:
def get_serializer_class(self):
method = self.request.method
if method == 'PUT' or method == 'POST':
return YourWriteSerializer
else:
return YourReadSerializer
I thought to add this one, since i came here from Googling after a while.