HttpResponse("
Here's the text of the Web page.
") 服务器直接返回一段字符串给客户端浏览器 或者用它返回一个文件HttpResponse(json_str, content_type='application/json; charset=utf-8')render render_to_response
这里的render()不是django.template的t.render(),而是最近Django版本新增的django.shortcuts.render(),类似django.shortcuts.render_to_response(),但这个render()是用来替代render_to_response(),在提到,
This function preceded the introduction of render() and works similarly except that it doesn’t make the request available in the response.
It’s not recommended and is likely to be deprecated in the future.
不建议再用render_to_response,用render代替。
render默认要求带入request,虽然render_to_response也可以用RequestContext将request参数带入。