RetrieveUpdateDestroyAPIView return 204 http status when receive Delete request
Here is my class-based view:
class BookDetail(generics.RetrieveUpdateDestroyAPIView): permission_classes = (permissions.IsAuthenticated,) queryset = Book.objects.all() serializer_class = BookSerializer
When i send the delete request http://10.0.3.2:8000/ecard/book/id=2/, http status 204 is returned, the book is successfully deleted, but how can i get the 200 status in this case ?
I found the answer: http://www.cdrf.co/3.1/rest_framework.mixins/DestroyModelMixin.html
def destroy(self, request, *args, **kwargs): instance = self.get_object() self.perform_destroy(instance) return Response(status=status.HTTP_204_NO_CONTENT)
Just rewrite your desire status code, in my case is status.HTTP_200_OK