simple bootstrap support for django
Project description
Bootstrap forms for Django
Bootstrap integration for django using widget templates.
Motivation
This library is meant to be a drop-in replacement for django-bootstrap5. 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-bs==4.*' # for bootstrap 4
pip install 'django-bs==5.*' # for bootstrap 5
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_bs). This is required so that widget
templates can be overwritten:
INSTALLED_APPS = [
…
'django_bs',
…
'django.forms',
…
]
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
Usage
The following template tags are included in the bootstrap 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 fromdjango.contrib.messages.bootstrap_pagination {page}- Render pagination. You should wrap it in a<nav>element with a meaningfularia-labelyourself.
Please refer to the source code for additional parameters.
Differences to django-bootstrap5
- 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. - Also overwrites the default form template in Django 4.0 and later so that
{{ form }}does the right thing automatically. - Concentrates on form fields and does therefore not include some other features.
- Uses
.form-text.text-dangerinstead of.invalid-feedbackas it does not depend on DOM location. (see also twbs/bootstrap#29439) - Uses Django's
required_css_classwhich is defined on theFormclass and added to the<label>. - Does not use
.is-validbecause I find it confusing with server-side rendering. - Does not include dismiss-buttons for alerts to avoid depending on JavaScript.
- Non-field errors are styled as alerts.
- Improved accessibility.
- You will have to load bootstrap yourself.
- No configuration.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_bs-5.4.1.tar.gz.
File metadata
- Download URL: django_bs-5.4.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82d87fdd71180d28713f5495c2c38eabcd5d25b042ca9bc5b0c76a790f2919df
|
|
| MD5 |
e7564d56688217b22e3e5dfbf933f1b8
|
|
| BLAKE2b-256 |
f37e3cbfabd336b200cddf162eae2674ad6ff4aae2cf3f77382b8cbcfa08c860
|
Provenance
The following attestation bundles were made for django_bs-5.4.1.tar.gz:
Publisher:
main.yml on xi/django-bs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_bs-5.4.1.tar.gz -
Subject digest:
82d87fdd71180d28713f5495c2c38eabcd5d25b042ca9bc5b0c76a790f2919df - Sigstore transparency entry: 834865413
- Sigstore integration time:
-
Permalink:
xi/django-bs@f986e11d429f346d35f418d7874b526d45ba6e2f -
Branch / Tag:
refs/tags/5.4.1 - Owner: https://github.com/xi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@f986e11d429f346d35f418d7874b526d45ba6e2f -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_bs-5.4.1-py3-none-any.whl.
File metadata
- Download URL: django_bs-5.4.1-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbe88aefbc1113d65f3924493c90e9d6e809f377184e7a56fc9feb1459178ef9
|
|
| MD5 |
aa06a2eda8c70267159fe9d02158c068
|
|
| BLAKE2b-256 |
e7e9dc1b756b25f6ff123812f76a02a5796601d605faa9746aca255878662ba6
|
Provenance
The following attestation bundles were made for django_bs-5.4.1-py3-none-any.whl:
Publisher:
main.yml on xi/django-bs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_bs-5.4.1-py3-none-any.whl -
Subject digest:
bbe88aefbc1113d65f3924493c90e9d6e809f377184e7a56fc9feb1459178ef9 - Sigstore transparency entry: 834865414
- Sigstore integration time:
-
Permalink:
xi/django-bs@f986e11d429f346d35f418d7874b526d45ba6e2f -
Branch / Tag:
refs/tags/5.4.1 - Owner: https://github.com/xi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@f986e11d429f346d35f418d7874b526d45ba6e2f -
Trigger Event:
push
-
Statement type: