code: def finalize_response(self, request, response, *args, **kwargs):
          
          # Make the error obvious if a proper response is not returned
          assert isinstance(response, HttpResponseBase), (
              'Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` '
              'to be returned from the view, but received a `%s`'
              % type(response)
          )
  
          if isinstance(response, Response):
              if not getattr(request, 'accepted_renderer', None):
                  neg = self.perform_content_negotiation(request, force=True)
                  request.accepted_renderer, request.accepted_media_type = neg
  
              response.accepted_renderer = request.accepted_renderer
              response.accepted_media_type = request.accepted_media_type
              response.renderer_context = self.get_renderer_context()
  
          for key, value in self.headers.items():
              response[key] = value
  
          return response
docs: Returns the final response object.