{"id":8912,"library":"crispy-bootstrap3","title":"Crispy Bootstrap3","description":"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.","status":"active","version":"2024.1","language":"en","source_language":"en","source_url":"https://github.com/django-crispy-forms/crispy-bootstrap3","tags":["django","forms","bootstrap3","frontend","template-pack","crispy-forms"],"install":[{"cmd":"pip install crispy-bootstrap3","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This 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.","package":"django-crispy-forms"},{"reason":"django-crispy-forms is a Django application, making Django itself a necessary dependency. Requires Django >= 3.2.","package":"Django"}],"imports":[{"note":"This is a Django template tag library, not a Python import. It's used in HTML templates to enable crispy forms rendering.","symbol":"crispy_forms_tags","correct":"{% load crispy_forms_tags %}"}],"quickstart":{"code":"import os\n\n# settings.py\n# ...\nINSTALLED_APPS = [\n    # ...\n    'crispy_forms',\n    'crispy_bootstrap3',\n    # ...\n]\n\nCRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap3'\nCRISPY_TEMPLATE_PACK = 'bootstrap3'\n\n# forms.py (example Django Form)\nfrom django import forms\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.layout import Layout, Submit\n\nclass ContactForm(forms.Form):\n    name = forms.CharField(label=\"Your Name\")\n    email = forms.EmailField(label=\"Your Email\")\n    message = forms.CharField(widget=forms.Textarea, label=\"Your Message\")\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.layout = Layout(\n            'name',\n            'email',\n            'message',\n            Submit('submit', 'Submit', css_class='btn-primary')\n        )\n\n# my_template.html (example Django template)\n# Make sure Bootstrap 3 CSS and JS are linked in your base template\n# {% load crispy_forms_tags %}\n# <form method=\"post\">\n#     {% csrf_token %}\n#     {% crispy form %}\n# </form>","lang":"python","description":"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."},"warnings":[{"fix":"Install `crispy-bootstrap3` via `pip install crispy-bootstrap3` and add `'crispy_bootstrap3'` to your `INSTALLED_APPS` list in `settings.py`.","message":"Template 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`.","severity":"breaking","affected_versions":"django-crispy-forms < 2.0 (when upgrading to >= 2.0)"},{"fix":"Ensure Bootstrap 3 CSS and JS files are linked in your base Django template (`<link>` and `<script>` tags).","message":"`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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Ensure 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install crispy-bootstrap3` and ensure `'crispy_bootstrap3'` is listed in your `INSTALLED_APPS` in `settings.py`.","cause":"The `crispy-bootstrap3` package has not been installed or has not been added to your `INSTALLED_APPS` in `settings.py` after upgrading `django-crispy-forms` to version 2.0 or newer.","error":"ModuleNotFoundError: No module named 'crispy_bootstrap3'"},{"fix":"Verify `crispy-bootstrap3` is installed and in `INSTALLED_APPS`. Check `CRISPY_TEMPLATE_PACK = 'bootstrap3'` in `settings.py`. Ensure `django-crispy-forms` is version 2.0 or higher.","cause":"This typically means `crispy_bootstrap3` is either not installed, not added to `INSTALLED_APPS`, or the `CRISPY_TEMPLATE_PACK` setting is incorrect or pointing to a non-existent template pack. It can also occur if `django-crispy-forms` is too old (pre-2.0) and doesn't expect template packs to be separate.","error":"django.template.exceptions.TemplateDoesNotExist: bootstrap3/uni_form.html (or similar path)"},{"fix":"Confirm Bootstrap 3 CSS and JavaScript are loaded in your base HTML. Double-check `CRISPY_TEMPLATE_PACK = 'bootstrap3'` in `settings.py`. Ensure `{% load crispy_forms_tags %}` is present in your template.","cause":"The Bootstrap 3 CSS/JS files are missing from your HTML templates, or the `CRISPY_TEMPLATE_PACK` setting is not correctly configured to 'bootstrap3', or a frontend framework (e.g. CDN) is using a different version of Bootstrap.","error":"Forms are not styled correctly (e.g., no Bootstrap classes applied, plain HTML)"}]}