If I have a class view that looks like this,
class MovieDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Movie.objects.all()
serializer_class = MovieSerializer
how do I make the serialize accept partial updates? currently where it stands Put will erase an existing data for said object.
Or you can just overwrite the get_serializer() method as:
It is especially useful when the front-end guy use the ngResource of the AngularJS to call your API, which only supports the 'put' instead of the 'patch' by default.
Hope it helps.
If you are using the DRF route, use
PATCH
method instead ofPUT
.if you write the urls configuration by yourself, dispatch it to
partial_update
method in yourRetrieveUpdateDestroyAPIView
view.If you get the serialize by yourself, pass the
partial=True
to your Serializer