Skip to main content

The best way to highlight active links in your Django app.

Project description Updates

The simplest way to highlight active links in your Django app.


The full documentation is at

Quick start

Install Django Active Link:

pip install django-active-link

Add it to your INSTALLED_APPS:


To use the active_link template tag you need to load active_link_tags templatetags library:

{% load active_link_tags %}

To add an active CSS class to a link when the request path matches a given view just do something like this.

<a href="{% url 'view-name' %}" class="{% active_link 'view-name' %}">Menu item</a>

You can even add the active class when the request path matches multiple views. Just pass the view names separated by a double pipe (||) as first argument to the active_link tag.

<a href="{% url 'view-name' %}" class="{% active_link 'view-name || view-sub-name' %}">Menu Item</a>

You can also use a custom CSS class:

<a href="{% url 'view-name' %}" class="{% active_link 'view-name' 'custom-class' %}">Menu item</a>


<a href="{% url 'view-name' %}" class="{% active_link 'view-name' css_class='custom-class' %}">Menu item</a>

By default active_link will not perform a strict match. If you want to add the active class only in case of a strict match pass the strict argument to the tag:

<a href="{% url 'view-name' %}" class="{% active_link strict=True %}">Menu item</a>

Replace view-name with the name of your view (including namespaces).


You can override the default active class and strict mode with the settings ACTIVE_LINK_CSS_CLASS and ACTIVE_LINK_STRICT.

Key Description Default Value
ACTIVE_LINK_CSS_CLASS Active class to use. active
ACTIVE_LINK_STRICT Designates whether to perform a strict match or not. False

For more usage examples, please check the full documentation at

IMPORTANT: Django Active Link requires that the current request object is available in your template’s context. This means you must be using a RequestContext when rendering your template, and django.core.context_processors.request must be in your TEMPLATE_CONTEXT_PROCESSORS setting. See for more information.


  • Write the documentation

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox


Tools used in rendering this package:


0.1.6 (2019-05-26)

Important changes

  • Silent error when view name not found
  • Update test jobs on Travis CI

0.1.5 (2018-05-25)

  • Minor improvements

0.1.4 (2018-04-07)

  • Minor improvements

0.1.3 (2018-02-18)

  • Minor improvements

0.1.2 (2018-01-07)

  • Minor improvements

0.1.1 (2017-10-11)

  • Minor improvements

0.1.0 (2017-07-10)

  • First release on PyPI.

Project details

Download files

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

Files for django-active-link, version 0.1.8
Filename, size File type Python version Upload date Hashes
Filename, size django_active_link-0.1.8-py2.py3-none-any.whl (5.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-active-link-0.1.8.tar.gz (7.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page