我在类中调用一个类视图。Call_view的值是“ InsertionOrder”,但是直接写“ InsertionOrder”是行不通的。值是动态的,所以我不能直接写“ InsertionOrder”。该怎么做? >
错误显示:“ str”对象在django中没有属性“ as_view”
class GenericDetailView(APIView):
def put(self, request,pk, format=None):
url_name = request.resolver_match.url_name
call_view = url_name.split("_")[0].title().replace('-', '')
return call_view.as_view()(request._request, format) this does not
# return InsertionOrder.as_view()(request._request, format) this works
class InsertionOrder(APIView):
#Code goes on