{"id":7165,"library":"django-bootstrap4","title":"Bootstrap 4 for Django","description":"django-bootstrap4 seamlessly integrates Bootstrap 4 into Django projects, providing template tags and filters for easy rendering of Bootstrap components. As of version 26.1, the library is in maintenance mode, receiving only bug fixes and security updates. This is due to Bootstrap 4 being superseded by Bootstrap 5, and new projects are encouraged to use the dedicated `django-bootstrap5` package.","status":"maintenance","version":"26.1","language":"en","source_language":"en","source_url":"https://github.com/zostera/django-bootstrap4","tags":["django","bootstrap","frontend","forms","template-tags","css","javascript","maintenance-mode"],"install":[{"cmd":"pip install django-bootstrap4","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Framework integration. Supports currently maintained Django versions (e.g., 4.x, 5.x, 6.x for latest django-bootstrap4).","package":"Django","optional":false},{"reason":"Runtime environment.","package":"Python","optional":false}],"imports":[{"note":"Older versions or forks sometimes used 'bootstrap_tags', but 'bootstrap4' is the correct and current template tag library name for this package.","wrong":"{% load bootstrap_tags %}","symbol":"bootstrap4 template tags","correct":"{% load bootstrap4 %}"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    # ...\n    'bootstrap4',\n    # ...\n]\n\n# templates/base.html (or any template using Bootstrap)\n{% load bootstrap4 %}\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, shrink-to-fit=no\">\n    {% bootstrap_css %}\n    <title>My Django App</title>\n</head>\n<body>\n    <div class=\"container\">\n        <h1>Hello, Bootstrap 4!</h1>\n        <form method=\"post\">\n            {% csrf_token %}\n            {% bootstrap_form form %}\n            {% buttons %}\n                <button type=\"submit\" class=\"btn btn-primary\">Submit</button>\n            {% endbuttons %}\n        </form>\n    </div>\n    {% bootstrap_javascript %}\n</body>\n</html>","lang":"python","description":"After installing, add 'bootstrap4' to `INSTALLED_APPS` in your Django `settings.py`. In your templates, load the `bootstrap4` template tag library and use `{% bootstrap_css %}` and `{% bootstrap_javascript %}` to include Bootstrap's assets. Forms can be easily rendered using `{% bootstrap_form form %}`."},"warnings":[{"fix":"For new projects, start with `django-bootstrap5`. For existing projects, plan for eventual migration to Bootstrap 5 or accept limited future enhancements.","message":"The library is in maintenance mode. No new features will be added, only bug fixes and security updates. For new projects, consider using `django-bootstrap5`.","severity":"breaking","affected_versions":"All versions from 21.1 (Nov 2021) onwards."},{"fix":"If icons are needed, integrate a separate icon library like Font Awesome or use `django-icons` in conjunction with `django-bootstrap4`.","message":"Bootstrap 4 (and thus django-bootstrap4) does not include an icon set by default, unlike Bootstrap 3. The `bootstrap_icon` template tag was removed.","severity":"breaking","affected_versions":"All versions."},{"fix":"Ensure `STATIC_ROOT` is defined in `settings.py`, and run `python manage.py collectstatic` on your deployment server. Verify your web server is configured to serve files from `STATIC_ROOT`.","message":"Static assets (CSS, JavaScript) may not load in production environments (`DEBUG=False`) if Django's static files are not properly configured and collected.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Carefully review the official Bootstrap migration guide for changes in classes, components, and JavaScript behavior. Update templates and custom CSS accordingly.","message":"Migrating from `django-bootstrap3` or a Bootstrap 3 project to `django-bootstrap4` is not fully backwards compatible and requires referring to the official Bootstrap 3 to 4 migration guide for client-side changes.","severity":"breaking","affected_versions":"Versions 1.0.0+ (when Bootstrap 4 was introduced)."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `'bootstrap4'` to the `INSTALLED_APPS` list in your `settings.py` file.","cause":"The 'bootstrap4' app is not added to Django's INSTALLED_APPS.","error":"TemplateSyntaxError: 'bootstrap4' is not a registered tag library"},{"fix":"Ensure `{% bootstrap_css %}` is in your `<head>` and `{% bootstrap_javascript %}` is placed just before the closing `</body>` tag in your base template. Check your browser's developer console for any loading errors or JavaScript conflicts.","cause":"Bootstrap CSS/JS files are not correctly loaded in the template, or JavaScript dependencies (like jQuery, Popper.js) are missing/loaded in the wrong order.","error":"Bootstrap styles (CSS) are not applying, or JavaScript components are not working (e.g., dropdowns, modals)"},{"fix":"To render an entire form, use `{% bootstrap_form form %}`. For individual fields, use `{% bootstrap_field field %}` or iterate `{% for field in form %}{% bootstrap_field field %}{% endfor %}`.","cause":"You are either not using the `{% bootstrap_form form %}` template tag, or form fields are being rendered individually without the `bootstrap_field` filter.","error":"My forms are not rendering with Bootstrap styling even after loading bootstrap4 tags."}]}