Skip to main content

Bootstrap template support for Django projects

Project description

This library was created to make django work with some generic bootstrap4 templates. This library uses the basic functionality from django-bootstrap4. I use it to match templates with my django_materialize_nav library.


Install the library.

# project/


Setup Context Processors

Bootstrap4_nav comes with a context processor to use some settings to change the default base styling.

# Context Processor to work with settings
        'OPTIONS': {
            'context_processors': [

Alternative way to get the standard context for views


from bootstrap4_nav.context_processors import get_context

def show_page(request):
    # Get the context with the style settings
    context = get_context(site_name='demo', title='Basic Content')

    context["object"] = "MyObject"
    return render(request, "my_page.html", context)


The base template can be used by extending the materialize base nav.

{% extends "bootstrap4_nav/base.html" %}

{% block nav_items %}
    <li class="navbar-item{% if title == 'Page1' %} active{% endif %}"><a class="nav-link" href="/">Page1</a></li>
    <li class="navbar-item{% if title == 'Page2' %} active{% endif %}"><a class="nav-link" href="/">Page2</a></li>
    <li class="navbar-item{% if title == 'Page3' %} active{% endif %}"><a class="nav-link" href="/">Page3</a></li>
{% endblock %}

{% block contents %}
    <p>My Content goes here</p>
{% endblock %}

Styling controls

Bootstrap4_nav comes with several style options used in the template context variables listed below.


If you went through the Setup Context Processors step then you can modify several settings to change the default style. This is an alternative to manually providing all of the template context variables.


BOOTSTRAP4_SITE_NAME = None  # Display this name in the navbar as the main name
BOOTSTRAP4_TITLE = None  # This is the page title displayed as the browser tab name

Project details

Download files

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

Files for django-bootstrap4-nav, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_bootstrap4_nav-0.0.1.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page