I want to use django-rest-framework with cache.
@cache_page(10 * 60)
@api_view(['GET'])
def get_num(request):
if request.method == "GET":
res = ["ok"]
return Response(res)
It works well.
So actually I want to cache not view but function
@cache_page(10 * 60)
def getCalc(num):
return num * 10
@api_view(['GET'])
def get_num(request):
if request.method == "GET":
res = getCalc(request.query_params.get('num'))
return Response(res)
There comes error TypeError: _wrapped_view() missing 1 required positional argument: 'request'
Is it possible to use cache for function??