{"id":7166,"library":"django-bootstrap5","title":"Django Bootstrap 5","description":"django-bootstrap5 is a Django app that provides Bootstrap 5 integration for Django projects, offering a collection of template tags and filters to seamlessly blend Django forms, messages, and other components with Bootstrap 5. It is actively maintained and considered production-ready, with frequent releases to keep up with Bootstrap and Django updates.","status":"active","version":"26.2","language":"en","source_language":"en","source_url":"https://github.com/zostera/django-bootstrap5","tags":["Django","Bootstrap","Frontend","Web Development","Forms","Styling"],"install":[{"cmd":"pip install django-bootstrap5","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core framework integration; supports Django >=3.2 (and newer actively supported versions like 6.0).","package":"Django","optional":false},{"reason":"Runtime environment; requires Python >=3.10.","package":"Python","optional":false}],"imports":[{"note":"The correct app name for `django-bootstrap5` in `INSTALLED_APPS` is `django_bootstrap5`. Using `bootstrap5` is a common mistake, often due to confusion with the older `django-bootstrap-v5` package.","wrong":"INSTALLED_APPS = (\n    # ...\n    \"bootstrap5\",\n    # ...\n)","symbol":"django_bootstrap5","correct":"INSTALLED_APPS = (\n    # ...\n    \"django_bootstrap5\",\n    # ...\n)"},{"note":"When loading template tags, use `{% load django_bootstrap5 %}`. `{% load bootstrap5 %}` refers to a different, potentially unmaintained, package or an older version.","wrong":"{% load bootstrap5 %}","symbol":"load django_bootstrap5","correct":"{% load django_bootstrap5 %}"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    # ...\n    'django.contrib.staticfiles',\n    'django_bootstrap5',\n    # ...\n]\n\n# myapp/templates/myapp/base.html (or any template using Bootstrap)\n{% load django_bootstrap5 %}\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>My Django App</title>\n    {% bootstrap_css %}\n</head>\n<body>\n    <div class=\"container\">\n        <h1>Hello Bootstrap 5!</h1>\n        <form method=\"post\" class=\"form\">\n            {% csrf_token %}\n            {% bootstrap_form form %}\n            {% bootstrap_button button_type=\"submit\" content=\"Submit\" %}\n        </form>\n    </div>\n    {% bootstrap_javascript %}\n</body>\n</html>","lang":"python","description":"After installation, add `django_bootstrap5` to your `INSTALLED_APPS`. In your Django templates, load the `django_bootstrap5` library using `{% load django_bootstrap5 %}`. Include `{% bootstrap_css %}` in your `<head>` and `{% bootstrap_javascript %}` before the closing `</body>` tag to load Bootstrap's CSS and JS. You can then use template tags like `{% bootstrap_form form %}` to render forms easily."},"warnings":[{"fix":"Replace `bootstrap4` with `django_bootstrap5` in `settings.py` (INSTALLED_APPS), template `{% load %}` statements, and `{% extends %}` statements.","message":"When migrating from `django-bootstrap4`, you must update all references from `bootstrap4` to `django_bootstrap5`. This includes `INSTALLED_APPS`, `{% load ... %}` tags in templates, and any template inheritance.","severity":"breaking","affected_versions":"All versions migrating from `django-bootstrap4`"},{"fix":"Manually add jQuery `<script>` tags to your templates if your project requires jQuery.","message":"Bootstrap 5 explicitly dropped jQuery support, and consequently, `django-bootstrap5` has removed all jQuery-related functions and tags. If your project still relies on jQuery for other purposes, you must include it manually; `{% bootstrap_javascript %}` will no longer provide it.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always use `django_bootstrap5` in `INSTALLED_APPS` and `{% load django_bootstrap5 %}` for this library. If switching, fully remove the other package and its references.","message":"There is a separate, often less maintained, package called `django-bootstrap-v5` which uses `bootstrap5` as its `INSTALLED_APPS` entry and template tag load name. Ensure you are consistently using `django-bootstrap5` and its corresponding `django_bootstrap5` names to avoid conflicts and unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the migration guide in the official documentation for a comprehensive list of changes. Update your templates and settings accordingly.","message":"Some template tags and settings from older `django-bootstrap` versions (e.g., `bootstrap4`) may have been removed or renamed in `django-bootstrap5` due to Bootstrap 5 API changes. Examples include removal of `InlineFieldRenderer` and simplification of size parameters.","severity":"gotcha","affected_versions":"All versions migrating from `django-bootstrap4`"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pip install django-bootstrap5` was run, and verify `INSTALLED_APPS` in `settings.py` contains `'django_bootstrap5'`.","cause":"The Django app was either not installed, not added to INSTALLED_APPS, or was added with the incorrect name (`bootstrap5` instead of `django_bootstrap5`).","error":"ModuleNotFoundError: No module named 'bootstrap5'"},{"fix":"Verify that `{% load django_bootstrap5 %}` is at the top of your template, and `{% bootstrap_css %}` is in the `<head>` section, and `{% bootstrap_javascript %}` is placed before the closing `</body>` tag. Also check `STATIC_URL` is configured if you're serving static files directly.","cause":"The Bootstrap CSS and/or JavaScript files are not being loaded in your template, or the template tags are not loaded correctly.","error":"My forms/pages are not styled by Bootstrap, or styling is broken."},{"fix":"Change `{% load bootstrap5 %}` to `{% load django_bootstrap5 %}` in your templates. If you intended to use `django-bootstrap-v5`, ensure it is installed and configured correctly instead.","cause":"You are attempting to load a tag library named `bootstrap5`, which belongs to a different package (`django-bootstrap-v5`), while having `django-bootstrap5` installed.","error":"TemplateSyntaxError: 'bootstrap5' is not a registered tag library"}]}