在模板中打印请求

时间:2010-12-10 10:33:23

标签: django django-models django-templates django-views

 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>

1 个答案:

答案 0 :(得分:1)

您是否已将django.core.context_processors.request添加到上下文处理器设置中? It's not enabled by default