Skip to main content

Django Bootstrap4 Nav

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.

Setup

Install the library.

# project/settings.py

INSTALLED_APPS = [
    "bootstrap4_nav",
    ...
]

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
TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'bootstrap4_nav.context_processors.get_context',
            ],
        },
    },
]

Alternative way to get the standard context for views

# views.py

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)

Style

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 %}
<div>
    <p>My Content goes here</p>
</div>
{% endblock %}

Styling controls

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

  • BOOTSTRAP4_SITE_NAME

  • BOOTSTRAP4_TITLE

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.

# settings.py

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

Metadata

Release files for bootstrap4-nav 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bootstrap4-nav 1.0.0
File Size Uploaded Provenance Actions
bootstrap4_nav-1.0.0.tar.gz 14.1 kB Without provenance Details for bootstrap4_nav-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bootstrap4-nav 1.0.0
File Interpreter ABI Platform Actions
bootstrap4_nav-1.0.0-py3-none-any.whl Python 3 none any Details for bootstrap4_nav-1.0.0-py3-none-any.whl

Total release size: 50.1 kB

Release files / bootstrap4_nav-1.0.0.tar.gz

Download URL bootstrap4_nav-1.0.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1b811361214674443d84fbb341a0e96f6cd8232c8c033b536c98f88ff7f874f9
BLAKE2b-256 checksum
How to use checksums
9a179871b0abe902ce1f5f689e5a7cf14513d0f2a9af4b64215fb683dcc3652d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

Release files / bootstrap4_nav-1.0.0-py3-none-any.whl

Download URL bootstrap4_nav-1.0.0-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b065d41ca8b61e6e71d1b010f9817fee0eeffe7c420eab84fe401628e40835c
BLAKE2b-256 checksum
How to use checksums
d3a2fbc0cc44c78327cc2da1574f460f199de16c4cf61e2b853fbe1c608f7757
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

Security for bootstrap4-nav 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page