The simplest way to highlight active links in your Django app.
Documentation
The full documentation is at https://django-active-link.readthedocs.io.
Quick start
Install Django Active Link:
pip install django-active-link
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'active_link',
...
)
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>
or:
<a href="{% url 'view-name' %}" class="{% active_link 'view-name' css_class='custom-class' %}">Menu item</a>
You can also define an inactive custom css class, that is triggered when a link is deemed not active:
<a href="{% url 'view-name' %}" class="{% active_link 'view-name' 'custom-class' 'not-active' %}">Menu item</a>
or:
<a href="{% url 'view-name' %}" class="{% active_link 'view-name' css_class='custom-class' css_inactive_class='not-active' %}">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).
Settings
You can override the default active class and strict mode with the settings ACTIVE_LINK_CSS_CLASS, ACTIVE_LINK_CSS_INACTIVE_CLASS and ACTIVE_LINK_STRICT.
Key |
Description |
Default Value |
|---|---|---|
ACTIVE_LINK_CSS_CLASS |
Active class to use. |
active |
ACTIVE_LINK_CSS_INACTIVE_CLASS |
Inactive class to use. |
|
ACTIVE_LINK_STRICT |
Designates whether to perform a strict match or not. |
False |
For more usage examples, please check the full documentation at https://django-active-link.readthedocs.io.
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.template.context_processors.request must be in your TEMPLATE_CONTEXT_PROCESSORS setting. See https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext for more information.
TODO
Write the documentation
Clean repository for unneccesary files
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install poetry (myenv) $ poetry install --only test (myenv) $ poetry run tox
Credits
Tools used in rendering this package:
Metadata
Release files for django-active-link 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_active_link-0.3.0.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_active_link-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / django_active_link-0.3.0.tar.gz
| Download URL | django_active_link-0.3.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0653ae337050ee1dd3559f7e2b86a202a8e1f9bc968a5968fcf65fbcb938fcad
|
|
BLAKE2b-256 checksum How to use checksums |
8db36cb02af7ac8bfacd4555ea7a480595dd50ff3feb21d5b00f548169387570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency logRelease files / django_active_link-0.3.0-py3-none-any.whl
| Download URL | django_active_link-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1db90d2b3405b6d8f4966b9c1a1f684b21147640a3ad636a43d58e95f930e97d
|
|
BLAKE2b-256 checksum How to use checksums |
7c790b452181cfd8fefe89f4fdd94e0d2782b8223f18b6422f44bbbdc4ca0271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency log