Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Bootstrap 5 integration for django using widget templates that were introduced in Django 1.11.

Motivation

This library is meant to be a drop-in replacement for django-bootstrap4. See below for a list of differences. I really like that library, but it is hard to customize some things because everything is done in python functions. By using widget templates, I hope this library is more flexible.

Installation

Install with pip:

pip install django-bs5

After that you have to add it to INSTALLED_APPS. You also need to make sure that the correct FORM_RENDERER is selected and django.forms is in INSTALLED_APPS (after django-bs5). This is required so that widget templates can be overwritten:

INSTALLED_APPS = [
    …
    'django-bs5',
    …
    'django.forms',
    …
]

FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'

Usage

The following template tags are included in the bootstrap4 library:

  • bootstrap_field {boundfield} - Render a single field.

  • bootstrap_form {form} - Render errors and all fields for a form. The <form> element itself is not included.

  • bootstrap_messages - Render messages from django.contrib.messages.

  • bootstrap_pagination {page} - Render pagination. A <nav> element is not included.

Please refer to the source code for additional parameters.

Differences to django-bootstrap4

  • Uses widget templates instead of custom renderers. IMHO this makes the code much easier to read and customize. A big downside is that I had to monkey-patch BoundField.as_widget() to include some information that would otherwise not be available in the widget templates.

  • Concentrates on forms fields and does therefore not include some others features.

  • Uses small.text-danger instead of .invalid-feedback as it does not depend on DOM location. (see also twbs/bootstrap#29439)

  • Does not use .is-valid because I find it confusing with server-side rendering.

  • Does not include dismiss-buttons for alerts to avoid depending on JavaScript.

  • Does not include field errors at the top of forms as they are already displayed on the fields themselves.

  • Improved ARIA support.

  • You will have to load bootstrap yourself.

  • No configuration.

Metadata

Release files for django-bs5 5.0.0b1.post1

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

Source distribution (sdist)

Source distribution for django-bs5 5.0.0b1.post1
File Size Uploaded
django-bs5-5.0.0b1.post1.tar.gz 7.4 kB Details

Release files / django-bs5-5.0.0b1.post1.tar.gz

Download URL django-bs5-5.0.0b1.post1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9dec5e0a0beebcb167617b52ae2b3868aa4ec5a6dc7058107bc09fa5df455bb2
BLAKE2b-256 checksum
How to use checksums
b7af61f7326e2bc20380d32df8e0b034c56c241a476ce10d9a03190631e0a080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

5.0.0b1.post1 This release

1 release file

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