【发布时间】:2016-07-19 09:42:22
【问题描述】:
我想向我的django view 中的另一台服务器发送http 请求,如下所示:
def django_view(request):
response = send_request('http://example.com')
result = do_something_with_response(response)
return HttpResponse(result)
我该怎么做?
【问题讨论】:
-
您可能正在寻找错误的东西。 “ajax”中的“j”代表 JavaScript,如果你想在 Python 中发出异步请求来修改你的视图,你必须实现某种 web 套接字来在请求完成时更新浏览器。对于这样的事情,您可能只需要在 JS 中将其编写为 jQuery ajax 请求或其他东西
-
@pdom:是的,我实际上需要一个 HttpRequest。谢谢。
标签: python django django-views httprequest