Bootstrap 5.3 template for django 4
Project description
Collapsible Sidebar Using Bootstrap for DJango
Collapsible Sidebar Using Bootstrap is a base template with a bootstrap simple customization in self-hosted mode (non-CDN).
Features:
- Bootstrap 5.3
- Django 4
- Templates included:
- bootstrap_base.html
- bootstrap_popovers.html
- registration/login.html
- snippets/show_err.html
- snippets/show_messages.html
- Bootstrap customization available at bootstrap-theme directory.
- Custom font from google-fonts in local static files.
Bootstrap theme and fonts are customizable using scripts included. See details bellow.
Preview
Installation
The preferred way to install is via pip
pip3 install django-bootstrap-sidebar
but you can install in develop mode cloning this repo but static files are not included in the repo. See Customize bootstrap theme section for details.
After installing your Django instance in settings.py
, add bootstrapsidebar
before django.contrib.auth
since some auth templates are overridden.
INSTALLED_APPS = [
'bootstrapsidebar'
'django.contrib.auth',
...
]
Testing example base-templates
To test the sidebar and login pages add to urls.py
:
from django.views.generic import TemplateView
from django.contrib.auth import views as auth_views
urlpatterns = [
...
path('demo',TemplateView.as_view(template_name="bootstrap_base.html"),name='demo'),
path('popovers',TemplateView.as_view(template_name="bootstrap_popovers.html"), name="popovers"),
path('login',auth_views.LoginView.as_view(), name="login"),
Pages can be tested at:
Blocks available in page layout
The base template (bootstrap_base.html
) includes the following hierarchical
blocks:
- block custom-css
- block head
- block page-wrapper: to override full page, included sidebar.
- block sidebar
- block navbar: to override top navbar
- navbar-links: only to add links in default template navbar.
- block messages: by default this block uses
snippets/show_messages.html
- block content
- block footer
- block after-bootstrap-js: used to run extra javascript like to enable Bootstrap Popovers. See below details
The registration/login.html
is an example page using base-template without
sidebar.
Customize bootstrap theme
Install the package in dev mode is recommended if you want to customize the Bootstrap Theme. First clone this repo and install in dev mode:
pip install -e ./django-bootstrap-sidebar
Bootstrap static files and fonts are not included in the repo. They are
generated/downloaded with the commands of makefile but the node environment
and npm
are required.
Bootstrap can be customized at file bootstrap-theme/custom.scss
. An easy way
to create a new customization is some online theme builder
like https://bootstrap.build/ and download the custom.scss.
To generate/upgrade static files makefile automates the process, run make:
make
Enable Bootstrap Popovers
Due performance reasons popovers are not default enabled. One way is to enable popovers everywhere, which requires an extra javascript after the Bootstrap javascript. The last solution is not optimal, but it is a simple way, a detailed instructions are available at Bootstrap Popovers
The block after-bootstrap-js
is intended to enable popovers and
the following code snippet from Bootstrap can be used:
{% block after-bootstrap-js %}
<script>
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
</script>
{% endblock %}
A full example is available at template bootstrap_popovers.html
License
The project is licensed under the Apache 2.0 license.
Author
Developed and maintained by Paulino Ruiz de Clavijo Vázquez pruiz@us.es
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_bootstrap_sidebar-1.2.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea2a405a371c5606352617f733bebc7fc10a14888ed0d1f220bad5bf0db5fc2c |
|
MD5 | e3aade2ac9fe0a3454e2b8b1bc01a458 |
|
BLAKE2b-256 | 823c0a35832e9aaf549cf9b0665da1d5e0da69d0c491c2ffda3b6fb236f9b8e2 |
Hashes for django_bootstrap_sidebar-1.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a1487479f7e68293713dfeed33372f91e6f07cb5d692afcf8d097a4955071d |
|
MD5 | 020144990f5fe0f1a97bbbeeacce3e6f |
|
BLAKE2b-256 | 968919c7e1632b96bd8a6500d181394c2cc8021ad1fce4ca27632663a62e2709 |