I'm new to Django world and I'm trying to build a Django application with 2 function based views wherein one function/view should be able to call the other view. The reason I'm trying to do this is to reduce avoid writing the logic again which is available in my other API.
@api_view(['POST'])
def PerformActionOne(request):
result_one = PerformActionTwo(request)
result_two = DoSomethingElse(result_one)
return Response(result_two)
@api_view(['POST'])
def PerformActionTwo(request):
# Performs some calculation and returns rest_framework.response Response with some data in it
# result is a dictionary
result = Calculate()
return Response(result)
In the above code I'm getting an error in this line result_one = PerformActionTwo(request)
Error: Exception Type: AssertionError Exception Value:
Therequestargument must be an instance ofdjango.http.HttpRequest, notrest_framework.request.Request.
I tried to look it up online and read documentation but I couldn't get a solution to this. I apologize if this is a duplicate question. Any leads on this will be greatly appreciated.