1

Seems like duplicate of this one, but still: I have JobCreateViewV1 (old one) view class which works with model in one way, and after upgrade, i created JobCreateViewV2 (new one) class that adds another entry to another model entry of first call. What is the best way to get response form first class and pass it to the second one?

Here are my classes: JobCreateView

class JobCreateView(AuthenticatedView, generics.GenericAPIView):
    #some seralizer
    serializer_class = JobSerializerForUser

    def post(self, request):
        #....yada yada yada...
        job='model is here'
        return Response(status=status.HTTP_201_CREATED, data=self.serializer_class(job, many=False).data)

and JobCreateViewV2

class JobCreateViewV2(AuthenticatedView, generics.ListAPIView):
    serializer_class = ResponsibleTechnicianSerializer

    def post(self, request):
        JobCreateViewV1Response = JobCreateViewV1.post(self, request)
        # ...yada yadayada...

        #and here JobCreateViewV1Response equals to {}

Old url works perfect, but when i call V2 one, data portion of response from V1 calls equals to {}. Might this problem occur because i call JobCreateView in improper way and serializer is not working the way it should? I've tried to use ShowAppsView.as_view()(self.request) approach, but it seems is not what i need.

Max Rukhlov
  • 331
  • 3
  • 12

1 Answers1

0

OldViewClass.post(self, request) works, but my problem was the old class inherits new class serializer, so old serializer should be explicitly passed to the old class.

Max Rukhlov
  • 331
  • 3
  • 12