Return to Snippet

Revision: 53028
at November 10, 2011 10:36 by magicrebirth


Initial Code
## settings.py
TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.contrib.messages.context_processors.messages",
	"django.core.context_processors.request",
	)


## views.py
from django.template import RequestContext

def home(request):
    return render_to_request('home.html', {}, context_instance=RequestContext(request))


## home.html
<div id="navigation">
    <a class="{% ifequal request.path "/" %}active{% endifequal %}" href="/">Home</a>
    <a class="{% ifequal request.path "/services/" %}active{% endifequal %}" href="/services/">Services</a>
    <a class="{% ifequal request.path "/contact/" %}active{% endifequal %}" href="/contact/">Contact</a>
</div>

Initial URL
http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/

Initial Description

                                

Initial Title
Adding request object info to a template

Initial Tags
template

Initial Language
Django