模板中的打印请求
def test4(request):
logging.debug(request)
logging.debug(request.META['HTTP_REFERER'])
return render_to_response('test2/test4.html', context_instance=RequestContext(request))
在上面的代码中,可以在 test4.html 中打印请求,也可以在我尝试过的 request.META['HTTP_REFERER'] 中打印
<script>
alert('{{request}}'); //prints empty
alert('{{request.META.HTTP_REFERER}}'); //prints empty
</script>
def test4(request):
logging.debug(request)
logging.debug(request.META['HTTP_REFERER'])
return render_to_response('test2/test4.html', context_instance=RequestContext(request))
In the above code can request be printed in the test4.html and also the request.META['HTTP_REFERER'] i had tried
<script>
alert('{{request}}'); //prints empty
alert('{{request.META.HTTP_REFERER}}'); //prints empty
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已将 django.core.context_processors.request 添加到上下文处理器设置中? 默认情况下未启用。
Have you added
django.core.context_processors.request
to your context processors setting? It's not enabled by default.