Registry / web-framework / crispy-bootstrap3

crispy-bootstrap3

JSON →
library2024.1pypypiunverified

Crispy Bootstrap3 is a template pack for `django-crispy-forms` that enables rendering Django forms with Bootstrap 3 styling. This package was originally included within the core `django-crispy-forms` library but was extracted into a standalone distribution starting with `django-crispy-forms` version 2.0. It provides a set of templates to integrate Bootstrap 3's grid system and form components into Django forms with minimal effort. The current version is 2024.1, with releases generally aligning with `django-crispy-forms` updates and continued Bootstrap 3 compatibility.

pip install crispy-bootstrap3
INSTALL
IMPORT
SIG · CRISPY-BOOTSTRAP3
C
crispy-bootstrap3
web-frameworkpythonv2024.1
Install
3.5s avg
Import
—
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2024.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.915 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.8MB
glibc
py 3.10–3.915 runs
installs and imports cleanly · install 3.5s · import 0.000s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

crispy_forms_tags
✓ {% load crispy_forms_tags %}
This is a Django template tag library, not a Python import. It's used in HTML templates to enable crispy forms rendering.

To integrate `crispy-bootstrap3`, first install the package. Then, add `'crispy_forms'` and `'crispy_bootstrap3'` to your `INSTALLED_APPS` in your Django `settings.py` file. Crucially, set `CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap3'` and `CRISPY_TEMPLATE_PACK = 'bootstrap3'` to activate the Bootstrap 3 template pack. In your Django templates, load the `crispy_forms_tags` library and render your form using `{% crispy form %}` for a complete form, or `{{ field|as_crispy_field }}` for individual fields. Remember to include Bootstrap 3's own CSS and JavaScript files in your project, as `crispy-bootstrap3` only provides the form rendering templates.

import os # settings.py # ... INSTALLED_APPS = [ # ... 'crispy_forms', 'crispy_bootstrap3', # ... ] CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap3' CRISPY_TEMPLATE_PACK = 'bootstrap3' # forms.py (example Django Form) from django import forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Submit class ContactForm(forms.Form): name = forms.CharField(label="Your Name") email = forms.EmailField(label="Your Email") message = forms.CharField(widget=forms.Textarea, label="Your Message") def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( 'name', 'email', 'message', Submit('submit', 'Submit', css_class='btn-primary') ) # my_template.html (example Django template) # Make sure Bootstrap 3 CSS and JS are linked in your base template # {% load crispy_forms_tags %} # <form method="post"> # {% csrf_token %} # {% crispy form %} # </form>
Debug
Known issues
breakingTemplate packs, including `crispy-bootstrap3`, were extracted from the core `django-crispy-forms` library starting with version 2.0. If you are upgrading `django-crispy-forms` from a version prior to 2.0 to 2.0 or newer, you must now explicitly install `crispy-bootstrap3` and add `'crispy_bootstrap3'` to your `INSTALLED_APPS` in `settings.py`.
fix
Install `crispy-bootstrap3` via `pip install crispy-bootstrap3` and add `'crispy_bootstrap3'` to your `INSTALLED_APPS` list in `settings.py`.
affects: django-crispy-forms < 2.0 (when upgrading to >= 2.0)
gotcha`crispy-bootstrap3` only provides the Django template rendering logic. It does *not* include the Bootstrap 3 CSS or JavaScript files themselves. You must manually include Bootstrap 3's static files (e.g., via CDN or local installation) in your project's HTML templates for the forms to be styled correctly.
fix
Ensure Bootstrap 3 CSS and JS files are linked in your base Django template (`<link>` and `<script>` tags).
affects: All versions
gotchaEnsure the `CRISPY_TEMPLATE_PACK` setting in `settings.py` correctly matches the template pack you intend to use (e.g., 'bootstrap3'). A mismatch, especially if you have multiple `crispy-bootstrapX` packages installed or a CDN for a different Bootstrap version, can lead to `TemplateDoesNotExist` errors or incorrectly styled forms.
fix
Verify that `CRISPY_TEMPLATE_PACK = 'bootstrap3'` is set in `settings.py` and that your frontend includes Bootstrap 3 assets, not Bootstrap 4 or 5.
affects: All versions
gotchaWhen using inline forms with `crispy-bootstrap3`, form errors (e.g., from validation failures) might not display by default. This is because the default `inline_field.html` template may not include the necessary logic to render error messages, unlike standard field templates.
fix
To display errors in inline forms, you may need to create a custom template for `inline_field.html` or override the relevant `bootstrap3/layout/help_text_and_errors.html` to ensure error rendering is included. Consult `django-crispy-forms` documentation on custom template overrides.
affects: All versions
Upgrade
Version history
2024.1latest on PyPI · released Jan 13, 2024
Audit
Dependencies
django-crispy-formsrequiredThis is a template pack for django-crispy-forms, thus requiring it to function. Version 2.0 or newer is required as this is when the template pack was extracted.
Djangorequireddjango-crispy-forms is a Django application, making Django itself a necessary dependency. Requires Django >= 3.2.
Agent activity
5 hits · last 30 days
node
4
Resources
crispy-bootstrap3 — pip install crispy-bootstrap3 · libregistry