I have a Django Rest Framework set up and I'd like to be able to send PATCH requests to it that update a specific field. I looked at some previous posts and incorporated the partial update
code in my view:
class RequestViewSet(viewsets.ModelViewSet):
queryset = Request.objects.filter(done = False).order_by('-time')
serializer_class = RequestSerializer
paginate_by = None
def partial_update(self, request, *args, **kwargs):
kwargs['partial'] = True
return self.update(request, *args, **kwargs)
When I try to run curl requests using PATCH, though, the object doesn't get updated. Here's an example of curl I was using:
curl --data '{"request": "foo"}' -X PATCH http://127.0.0.1:8000/api/request/1/
In the terminal, it returns the original, unmodified object. Is there a different way to set up the Model ViewSet to accept partial updates via PATCH?