【发布时间】:2021-02-09 05:55:25
【问题描述】:
我想在视图中发送一个 http 请求。请求 URL 与另一个视图有关。像这样的:
class View_A(APIView):
def get(self, request):
return Response({'foo':'bar'})
class View_B(APIView):
def post(self, request):
# Here I would want to send a request to View_A, something like this:
request_view_A = View_A.as_view().get('URL_FROM_VIEW_A')
# ...
return Response({'foo2':'bar2'})
我见过这个question 有不同的关注点,但是对我不起作用,因为来自View_A(get)的http 方法与来自View_B(post)的http 方法不同。
【问题讨论】:
标签: python django django-rest-framework django-views