Created
April 5, 2012 06:45
-
-
Save pylemon/2308518 to your computer and use it in GitHub Desktop.
django: get current url within template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## views.py | |
from django.shortcuts import render_to_response | |
from django.template.context import RequestContext | |
def home(request): | |
return render_to_response('home.html', {}, | |
context_instance=RequestContext(request)) | |
## don't forget RequestContext, that makes request var can be used in templates | |
## in template it can be used like this | |
# {{ request.path }} | |
## adding following stuff to settings.py | |
# TEMPLATE_CONTEXT_PROCESSORS = ( | |
# 'django.core.context_processors.request', | |
# ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment