'recall class if a condition is met (Python - Django)

I am using Django-rest-framework to create an API. My API is something like:

class SampleApi(APIView):
    def get(self, request):
        my_var = self.abc(request, firstname)
        self.xyz(request, lastname)
        if my_var == 0:
            **# call the api again**
        else:
            # Do other stuff
            pass

    @staticmethod
    def abc(request, firstname):
        # do some task
        pass

    @staticmethod
    def xyz(request, lastname):
        # do some task
        pass

I want to call the same api again if my if condition is matched. Can anyone please guide me here. Thanks!!



Solution 1:[1]

Maybe you can recall that function.

class SampleApi(APIView):
    def get(self, request):
        my_var = self.abc(request, firstname)
        self.xyz(request, lastname)
        if my_var == 0:
            self.get(request)
        else:
            # Do other stuff
            pass

    ...

Hope it could help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Lu