2013-02-19 70 views

回答

28

render的結果分配給一個變量,設置標題,然後返回響應。

response = render(request, "template.html", {}) 
response['Cache-Control'] = 'no-cache' 
return response 

大多數時候,它是簡單的用戶renderrender_to_response。但是,如果您使用的是render_to_response,則採用相同的方法:

response = render_to_response("template.html", {}) 
response['Cache-Control'] = 'no-cache' 
return response