Delete method on Django Rest Framework ModelViewSet

后端 未结 2 1631
北荒
北荒 2021-02-05 17:20

i have tried to delete a single ManuscriptItem instance using Postman to perform my API requests on against the view below:

class ManuscriptViewSet(viewsets.Mode         


        
2条回答
  •  时光取名叫无心
    2021-02-05 17:55

    def destroy(self, request, *args, **kwargs):
            try:
                instance = self.get_object()
                self.perform_destroy(instance)
            except Http404:
                pass
            return Response(status=status.HTTP_204_NO_CONTENT)
    

    use this and it will work

提交回复
热议问题