我想将X-Frame-Options ALLOWALL
添加到某个页面的标题中(对于某些远程ajax调用)。
我的观点很简单,就像这样:
def info(request):
return render_to_response("info.html",
locals(),
context_instance=RequestContext(request))
如何修改标题内容?
答案 0 :(得分:3)
使用render()
而不是使用render_to_response()def info(request):
data = render(request, 'info.html')
response = HttpResponse(data)
response['X-Frame-Options'] = "ALLOWALL"
return response
还有全球环境。要使用它,请将其添加到中间件:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
并添加到设置X-Frame-Options = 'ALLOWALL'
,但这通常不是一个好主意,除非您确切知道自己在做什么。