Print request in template
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>
Have you added django.core.context_processors.request
to your context processors setting? It's not enabled by default.
精彩评论