Skip to main content

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


Download files

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

Source Distribution

django-breadcrumbs-util-1.2.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file django-breadcrumbs-util-1.2.tar.gz.

File metadata

  • Download URL: django-breadcrumbs-util-1.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for django-breadcrumbs-util-1.2.tar.gz
Algorithm Hash digest
SHA256 4360d6ce22ad483e67a4622acc150fd3acfc27adee98977956b816378975f3b0
MD5 d55bb92774959b51f11cc2f519dcdf6b
BLAKE2b-256 d30d5e7b8f08f65bfc93457781aed463c3377ea6072ce04f7a9a17726c11d812

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page