crispy-bootstrap4

2026.2 · active · verified Wed Apr 15

crispy-bootstrap4 is a template pack for django-crispy-forms, providing Bootstrap 4 styling for Django forms. It facilitates rendering forms elegantly without extensive manual HTML, offering control over layout and appearance. The library is actively maintained, with a version 2026.2 released on February 11, 2026, and follows a frequent release cadence, often coinciding with Django and Python version updates.

Warnings

Install

Imports

Quickstart

To use crispy-bootstrap4, add 'crispy_forms' and 'crispy_bootstrap4' to your `INSTALLED_APPS` in `settings.py`. Then, set `CRISPY_TEMPLATE_PACK = 'bootstrap4'` to make it the default template pack. In your Django templates, load `crispy_forms_tags` and render your form using `{% crispy form %}`. Remember to manually include Bootstrap 4's CSS and JavaScript in your base templates, as crispy-bootstrap4 only provides the template logic, not the static assets.

# settings.py
INSTALLED_APPS = [
    # ... other Django apps
    'crispy_forms',
    'crispy_bootstrap4',
]

CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap4'
CRISPY_TEMPLATE_PACK = 'bootstrap4'

# my_app/forms.py
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', 'Send Message', css_class='btn-primary')
        )

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Us</title>
    <!-- Include Bootstrap 4 CSS and JS manually -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        <h1>Contact Us</h1>
        <form method="post">
            {% csrf_token %}
            {% crispy form %}
        </form>
    </div>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

view raw JSON →