django-bootstrap-navbar 0.0.22

Creator: danarutscher

Last updated:

Add to Cart

Description:

djangobootstrapnavbar 0.0.22

django-bootstrap-navbar


A code based navbar with great ambitions.

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:

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",
]
},
}
]


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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.