A package that provides a simple way to add breadcrumbs to your Django views
Project description
Django Breadcrumbs Utils
Django Breadcrumbs Utils is a package that provides a simple way to add breadcrumbs to your Django views.
Installation You can install the package via pip:
Deployment
To deploy this project run
pip install django-breadcrumbs-utils
Usage
To use the custom_path function from the package, import it into your urls.py file and use it to define your URL patterns:
from breadcrumbs import custom_path
urlpatterns = [
custom_path('my-route/', my_view, name='my-view', breadcrumb='My View'),
# ...
]
The custom_path function takes a route argument, a view function, a name argument (optional), and a breadcrumb argument (optional).
The breadcrumb argument should be a string that represents the label of the breadcrumb for the current page.
The custom_path function wraps your view function with a decorator that adds a breadcrumb variable to the context of the view function. The variable contains the breadcrumb label specified in the breadcrumb argument.
In your template
you can access the breadcrumb variable to display the breadcrumb:
{% block breadcrumbs %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ breadcrumb }}</li>
</ol>
</nav>
{% endblock %}
This will display a breadcrumb trail that starts with a link to the home page and ends with an active breadcrumb label for the current page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-breadcrumbs-util-1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4360d6ce22ad483e67a4622acc150fd3acfc27adee98977956b816378975f3b0 |
|
MD5 | d55bb92774959b51f11cc2f519dcdf6b |
|
BLAKE2b-256 | d30d5e7b8f08f65bfc93457781aed463c3377ea6072ce04f7a9a17726c11d812 |