{"id":4485,"library":"crispy-bootstrap5","title":"crispy-bootstrap5","description":"crispy-bootstrap5 is a Bootstrap 5 template pack for the popular `django-crispy-forms` library. It enables Django forms to be rendered with Bootstrap 5 styles and components, including features like floating labels, accordions, and switches. The library follows a CalVer versioning scheme and releases frequently to keep pace with Django and Bootstrap updates.","status":"active","version":"2026.3","language":"en","source_language":"en","source_url":"https://github.com/django-crispy-forms/crispy-bootstrap5","tags":["django","forms","bootstrap5","frontend","crispy-forms"],"install":[{"cmd":"pip install crispy-bootstrap5 django-crispy-forms","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"crispy-bootstrap5 is a Django app and requires Django to function.","package":"django"},{"reason":"crispy-bootstrap5 is a template pack for django-crispy-forms and requires it to render forms.","package":"django-crispy-forms"}],"imports":[{"note":"Used to programmatically define form rendering behavior.","symbol":"FormHelper","correct":"from crispy_forms.helper import FormHelper"},{"note":"Base class for defining form layouts. Other layout objects like Row, Column, Submit are also commonly imported from crispy_forms.layout.","symbol":"Layout","correct":"from crispy_forms.layout import Layout"},{"note":"A layout object for Bootstrap 5's floating labels. Other Bootstrap 5 specific layout objects like BS5Accordion and Switch are also imported from this module.","symbol":"FloatingField","correct":"from crispy_bootstrap5.bootstrap5 import FloatingField"},{"note":"Used to render a crispy form within Python code, for example in a Django view to return an AJAX response. Remember to pass the CSRF token via context if needed.","symbol":"render_crispy_form","correct":"from crispy_forms.utils import render_crispy_form"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    # ...\n    'crispy_forms',\n    'crispy_bootstrap5',\n    # ...\n]\n\nCRISPY_ALLOWED_TEMPLATE_PACKS = \"bootstrap5\"\nCRISPY_TEMPLATE_PACK = 'bootstrap5'\n\n# forms.py (example 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', max_length=100)\n    email = forms.EmailField(label='Your Email')\n    message = forms.CharField(label='Your Message', widget=forms.Textarea)\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 btn-primary')\n        )\n\n# views.py (example view)\nfrom django.shortcuts import render\nfrom .forms import ContactForm\n\ndef contact_view(request):\n    form = ContactForm()\n    return render(request, 'contact.html', {'form': form})\n\n# templates/contact.html\n{% load crispy_forms_tags %}\n\n<form method=\"post\">\n    {% csrf_token %}\n    {% crispy form %}\n</form>","lang":"python","description":"After installation, add `crispy_forms` and `crispy_bootstrap5` to `INSTALLED_APPS` in your `settings.py`. Then, configure `CRISPY_ALLOWED_TEMPLATE_PACKS` and `CRISPY_TEMPLATE_PACK` to 'bootstrap5'. In your Django template, load `crispy_forms_tags` and render your form using either `{{ form|crispy }}` for basic styling or `{% crispy form %}` if you've defined a `FormHelper` in your form class for advanced layout control."},"warnings":[{"fix":"Consult the release notes for the version you are upgrading to and ensure your Django and Python environment matches the supported ranges. Upgrade Django/Python if necessary.","message":"Major versions frequently drop support for older Django and Python versions. Always check release notes before upgrading. For instance, version 2026.3 dropped support for Django 4.2, 5.0, 5.1 and Python 3.8, 3.9, while adding support for Django 6.0 and Python 3.14.","severity":"breaking","affected_versions":"All versions (check release notes)"},{"fix":"Ensure you are using `django-crispy-forms` version 2.3 or higher when upgrading to `crispy-bootstrap5` 2024.10 or newer.","message":"Support for `django-crispy-forms` 2.2 and earlier was dropped in version 2024.10 of `crispy-bootstrap5`.","severity":"breaking","affected_versions":"2024.10+"},{"fix":"Upgrade to `crispy-bootstrap5` 2025.4 or newer to ensure full accessibility and compatibility with Django 5.2's updated form rendering.","message":"For Django 5.2 and newer, templates were updated to include `aria-describedby` for `<fieldset>` elements and a parent `<div>` for errors, improving accessibility. Older versions might not be fully accessible or compatible with Django 5.2's expectations without these changes.","severity":"gotcha","affected_versions":"Pre-2025.4 with Django 5.2+"},{"fix":"If you are customizing your form layout using `FormHelper`, always use `{% crispy form %}` in your templates. Use `{{ form|crispy }}` for simple forms without custom layouts.","message":"When using `FormHelper` to define complex layouts in your form, you should use the `{% crispy form %}` template tag instead of the `{{ form|crispy }}` filter. The filter provides basic rendering, similar to `as_p`, `as_ul`, or `as_table`, and does not allow for layout customization defined in `FormHelper`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"It is highly recommended to upgrade to a CalVer version (2023.10 or newer) to ensure you receive ongoing support and updates.","message":"Pre-CalVer versions (0.x) used a different versioning scheme and may not receive updates or support. The project switched to CalVer (YYYY.Minor) with version 2023.10.","severity":"deprecated","affected_versions":"< 2023.10"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}