Skip to content

Instantly share code, notes, and snippets.

@pylemon
Created April 5, 2012 06:45
Show Gist options
  • Save pylemon/2308518 to your computer and use it in GitHub Desktop.
Save pylemon/2308518 to your computer and use it in GitHub Desktop.
django: get current url within template
## 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