crispy-bootstrap5

2026.3 · active · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

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.

# settings.py
INSTALLED_APPS = [
    # ...
    'crispy_forms',
    'crispy_bootstrap5',
    # ...
]

CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = 'bootstrap5'

# forms.py (example 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', max_length=100)
    email = forms.EmailField(label='Your Email')
    message = forms.CharField(label='Your Message', widget=forms.Textarea)

    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 btn-primary')
        )

# views.py (example view)
from django.shortcuts import render
from .forms import ContactForm

def contact_view(request):
    form = ContactForm()
    return render(request, 'contact.html', {'form': form})

# templates/contact.html
{% load crispy_forms_tags %}

<form method="post">
    {% csrf_token %}
    {% crispy form %}
</form>

view raw JSON →