{"id":6577,"library":"crispy-bootstrap4","title":"crispy-bootstrap4","description":"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.","status":"active","version":"2026.2","language":"en","source_language":"en","source_url":"https://github.com/django-crispy-forms/crispy-bootstrap4","tags":["django","forms","bootstrap","bootstrap4","frontend","template-pack"],"install":[{"cmd":"pip install crispy-bootstrap4","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required as the core forms rendering library, crispy-bootstrap4 is a template pack for it.","package":"django-crispy-forms","optional":false},{"reason":"crispy-bootstrap4 is a Django application.","package":"Django","optional":false}],"imports":[{"note":"crispy-bootstrap4 is configured in Django's settings.py as an INSTALLED_APP. Note the use of underscore ('crispy_bootstrap4') in INSTALLED_APPS, not hyphen.","symbol":"crispy_forms","correct":"INSTALLED_APPS = [\n    # ...\n    'crispy_forms',\n    'crispy_bootstrap4',\n]"},{"note":"Set this in your Django settings.py to define the default template pack for crispy-forms.","symbol":"CRISPY_TEMPLATE_PACK","correct":"CRISPY_TEMPLATE_PACK = 'bootstrap4'"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    # ... other Django apps\n    'crispy_forms',\n    'crispy_bootstrap4',\n]\n\nCRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap4'\nCRISPY_TEMPLATE_PACK = 'bootstrap4'\n\n# my_app/forms.py\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', 'Send Message', css_class='btn-primary')\n        )\n\n# my_app/templates/my_app/contact.html\n{% load crispy_forms_tags %}\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Contact Us</title>\n    <!-- Include Bootstrap 4 CSS and JS manually -->\n    <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css\">\n</head>\n<body>\n    <div class=\"container\">\n        <h1>Contact Us</h1>\n        <form method=\"post\">\n            {% csrf_token %}\n            {% crispy form %}\n        </form>\n    </div>\n    <script src=\"https://code.jquery.com/jquery-3.5.1.slim.min.js\"></script>\n    <script src=\"https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js\"></script>\n    <script src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js\"></script>\n</body>\n</html>","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your Django project uses a currently supported version (e.g., Django 5.2 or 6.0 with crispy-bootstrap4 2026.2).","message":"Support for several Django versions has been removed in recent releases. Version 2026.2 dropped support for Django 4.2, 5.0, and 5.1. Version 2023.1 previously dropped Django 3.2, 4.0, and 4.1.","severity":"breaking","affected_versions":"2023.1, 2026.2 and later"},{"fix":"Upgrade your `django-crispy-forms` package to version 2.3 or higher.","message":"Support for `django-crispy-forms` 1.x was dropped in version 2023.1, and the minimum supported version was bumped to 2.3 in 2024.10.","severity":"breaking","affected_versions":"2023.1, 2024.10 and later"},{"fix":"Correct `INSTALLED_APPS = ('crispy-bootstrap4',)` to `INSTALLED_APPS = ('crispy_bootstrap4',)`.","message":"When adding to `INSTALLED_APPS` in `settings.py`, use the Python package name with an underscore: `crispy_bootstrap4`. Using the PyPI package name with a hyphen (`crispy-bootstrap4`) will result in an `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Include `<link>` tags for Bootstrap 4 CSS and `<script>` tags for Bootstrap 4 JavaScript (and its dependencies like jQuery and Popper.js) in your base HTML template.","message":"This template pack does not include Bootstrap 4's CSS or JavaScript assets. You must manually link to Bootstrap 4's CSS and JS files in your Django templates (e.g., via CDN or local static files) for forms to render with the correct styling.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review and update any custom frontend code that interacts with or styles form help text based on its `id` attribute to match the new structure introduced with Django 5.0+ compatibility.","message":"The `id` attribute for help text generated by forms changed in version 2025.6 to align with the `aria-describedby` attribute added by Django 5.0+. This might impact custom JavaScript or CSS that relied on the previous help text `id` structure.","severity":"gotcha","affected_versions":"2025.6 and later"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}