Skip to main content

Django navbar package

Project description

django-bootstrap-navbar

Code style: black coverage report

A code based navbar with great ambitions.

django-navbar

Usage

django-bootstrap-navbar lets you create a bootstrap 4 navbar with a Python class. It then takes care of setting the active class on the appropriate link based on the current path.

Install

The library is available on PyPi.

pip install django-bootstrap-navbar

Once you have created a navbar class there are two ways of making it available in your template context:

  1. Using the provided context processor
BOOTSTRAP_NAVBAR = "showcase.navbar:ExampleNavBar"

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        ...
            "context_processors": [
                "django.template.context_processors.debug",
                ...
                "bootstrap_navbar.navbars.context_processors.navbar",
            ]
        },
    }
]
  1. Using the provided mixin
class ContextProcessorView(BootstrapNavBarViewMixin, TemplateView):
    template_name = "index.html"
    navbar_class = AppNavBar

Finally the navbar can be rendered within your templates by calling the navbar.render method.

{{ navbar.render }}

A full example is available within the repo.

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_bootstrap_navbar-0.0.22.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file django_bootstrap_navbar-0.0.22.tar.gz.

File metadata

  • Download URL: django_bootstrap_navbar-0.0.22.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

File hashes

Hashes for django_bootstrap_navbar-0.0.22.tar.gz
Algorithm Hash digest
SHA256 a9e5eadb9917502611bbad7b6ffeb7702f0145245b8b43fbe74749f1f3811b9b
MD5 5772946447d3b6dec42ab2f596944ff0
BLAKE2b-256 476c1c36bc9e60201db1e04f51fa5dcf7563590ed5f59758f012f4363bcb042a

See more details on using hashes here.

Supported by

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