Skip to main content

Django navbar package

Project description

django-bootstrap-navbar

Coverage

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(DjangoNavBarViewMixin, 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.7.tar.gz (10.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: django_bootstrap_navbar-0.0.7.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for django_bootstrap_navbar-0.0.7.tar.gz
Algorithm Hash digest
SHA256 1939fb701624d980857382682d3f2cbff29a457d983423cdea532e60226a6be3
MD5 f01984064346ae188b702d274512f4d7
BLAKE2b-256 77b1e778a60386d097162fbb9f34a2492525565d73c4b37c29e4507f4720cf00

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