I'm having a viewset
class JobPostView(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated]
serializer_class = JobPostSerializer
queryset = JobPost
How will I return custom messages for each function? for eg. if using the get function, I have to return "listed successfully" with data, for the post "posted successfully" with data, likewise for put, patch and delete.
CodePudding user response:
ModelViewSet is inherited from GenericAPIView in DRF so you can override .list(), .retrieve(), .create(), .update(), .partial_update(), and .destroy() to put your custom logic and return your custom Response.
refer to DRF Documentation for further info.
