Search code examples
django-rest-frameworkdjango-generic-views

Override response of POST in Django Rest Framework


I'm using Django Rest Framework's Generics (generics.ListCreateAPIView), when I make a POST request I get a response of Http code (200/400/..etc.) and a JSON showing the posted data, I need to know how can I override the response to get a custom response.

Note that I use

    def perform_create(self,serializer):
        return Response(<my response>)

to override the POST request handling but I still get the same response


Solution

  • The response from perform_create is ignored. You'll likely want to override the create method using the mixins as example