Reputation: 29557
I am trying to get request.path in my template but I get nothing. Everything else on the page works fine. I have done:
In views.py
from django.template import RequestContext
return render_to_response('frontpage.html', {}, context_instance=RequestContext(request))
In my template frontpage.html
{{ request.path }}
What else am I missing? I'd post some code, but I don't know were to begin.
Edit: Am using localhost in case that matters.
Upvotes: 1
Views: 1353
Reputation: 28846
Make sure that your TEMPLATE_CONTEXT_PROCESSORS
setting includes django.core.context_processors.request
; that's what actually adds the request
variable. This isn't on by default.
(Also, django.shortcuts.render
is usually easier than render_to_response
with an explicit RequestContext
.)
Upvotes: 4