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 ?

Answers


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


Need Your Help

Oracle SQL - Alternative for dynamic query

sql oracle plsql

I have a procedure (see below) which is using dynamic query. I wanted to rewrite this procedure with out using dynamic query. How do I write the conditions below?

WxPython: deriving wx.ListItem but wx.ListCtrl only returns old class

python wxpython listctrl

I've got a small issue with derived classes, namely wx.ListItem with wx.ListCtrl. I succesfully derived wx.ListItem as a MediaItem, the code is not finished but you get the point: