Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

An example django template tag library for adding an "active" class to navigation links.

Project Description


A small template tag library for django, that makes highlighting active links easy.

visit the github.


This library is extremely light weight, and I probably won’t add any new features. There are many larger libraries out there that already provide many more features for navigation, so I’d suggeset that people use those instead.

This library is meant partially for people who just want one simple tag to add an “active” class to a navigation link, but mostly just as a simple example of how to create a template tag in django.


from the command line:

pip install django-urlactive-lite

In your file, add urlactive to INSTALLED_APPS


And add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS setting in Remember to include the other default template context processors:



{% url_active ... %}


The {% url_active ... %} template tag takes one argument, a url, and prints "active" if the url passed as an argument is the same as the url from which the page is rendered.


Don’t forget to load the template tag library.

{% load urlactive %}
<ul class="nav">
    {% url 'first_url_name' as first_url %}
    <li class="{% url_active first_url %}">
        <a href="{{ first_url }}"> First </a>

    {% url 'second_url_name' as second_url %}
    <li class="{% url_active second_url %}">
        <a href="{{ second_url }}">Second</a>

    {% url 'third_url_name' as third_url %}
    <li class="{% url_active third_url %}">
        <a href="{{ third_url }}">Third</a>


There are already many great projects for django around template tags for navigation, so I’m not looking to extend this project. Of course, feel free to fork it and do whatever you want with the code.

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(11.4 kB) Copy SHA256 Hash SHA256
Source Mar 20, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting