{"id":7164,"library":"django-bootstrap3","title":"Django Bootstrap3","description":"django-bootstrap3 is a Python library that integrates Bootstrap version 3 into Django projects. It provides template tags and filters to render forms, messages, and other Bootstrap components easily within Django templates. The current version is 26.1, and it maintains a steady release cadence.","status":"active","version":"26.1","language":"en","source_language":"en","source_url":"https://github.com/zostera/django-bootstrap3","tags":["django","bootstrap","frontend","forms","ui","template-tags"],"install":[{"cmd":"pip install django-bootstrap3","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for any Django project integration.","package":"Django","optional":false}],"imports":[{"note":"A utility function for programmatically adding CSS classes to HTML elements, though often handled via template tags.","symbol":"add_css_classes","correct":"from bootstrap3.utils import add_css_classes"},{"note":"Allows for programmatic rendering of Django form fields using Bootstrap 3 styling, complementing the template tag usage.","symbol":"render_field","correct":"from bootstrap3.forms import render_field"}],"quickstart":{"code":"{% load bootstrap3 %}\n<!DOCTYPE html>\n<html>\n<head>\n    <title>Django Bootstrap3 Example</title>\n    {% bootstrap_css %}\n    {% bootstrap_javascript %}\n    <style>\n        .container { margin-top: 20px; }\n    </style>\n</head>\n<body>\n    <div class=\"container\">\n        <h1>Contact Us</h1>\n        {% bootstrap_messages %}\n        <form action=\"\" method=\"post\" class=\"form\">\n            {% csrf_token %}\n            {% bootstrap_form form layout='horizontal' %}\n            {% buttons submit='Submit' %}\n                <button type=\"submit\" class=\"btn btn-primary\">\n                    <span class=\"glyphicon glyphicon-envelope\"></span> Submit\n                </button>\n            {% endbuttons %}\n        </form>\n    </div>\n</body>\n</html>","lang":"html","description":"To use `django-bootstrap3`, first install it with `pip install django-bootstrap3`. Then, add `'bootstrap3'` to your `INSTALLED_APPS` in `settings.py`. In any Django template where you want to use Bootstrap 3, include `{% load bootstrap3 %}` at the top, and then use tags like `{% bootstrap_css %}`, `{% bootstrap_javascript %}`, `{% bootstrap_messages %}`, and `{% bootstrap_form form %}`. This example demonstrates rendering a form passed as `form` in the template context."},"warnings":[{"fix":"For new projects or projects requiring modern Bootstrap features, use `django-bootstrap4` or `django-bootstrap5` instead. If you must use Bootstrap 3, be fully aware of its EOL status and associated risks.","message":"This library is exclusively for Bootstrap 3, which is an end-of-life (EOL) framework and no longer receives official updates or security patches. Using it in new projects or expecting compatibility with modern Bootstrap versions (4 or 5) is highly discouraged and will lead to broken layouts and potential security vulnerabilities.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure `INSTALLED_APPS` in your `settings.py` includes `'bootstrap3'`: `INSTALLED_APPS = ['...', 'bootstrap3', '...']`.","message":"Forgetting to add `'bootstrap3'` to your `INSTALLED_APPS` in `settings.py` will prevent the library's template tags from being recognized by Django, leading to `ImproperlyConfigured` errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always place `{% load bootstrap3 %}` as the very first line in any Django template that uses `django-bootstrap3` tags.","message":"Omitting `{% load bootstrap3 %}` at the beginning of your Django template will cause `TemplateSyntaxError` for all `bootstrap3`-related tags, as the tag library won't be available.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Include `{% bootstrap_css %}` and `{% bootstrap_javascript %}` in the `<head>` of your base template. For production, ensure `python manage.py collectstatic` has been run and static files are served.","message":"If your forms or other components are not displaying with Bootstrap 3 styles, you might be missing `{% bootstrap_css %}` and/or `{% bootstrap_javascript %}` in your template's `<head>` section, or static files are not served correctly in production.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `{% load bootstrap3 %}` as the very first line of your Django template file.","cause":"The `bootstrap3` template tag library was not explicitly loaded in the template.","error":"django.template.exceptions.TemplateSyntaxError: 'bootstrap3' is not a registered tag library, or is not available. Did you go and assign it a name and not use it?"},{"fix":"Open your `settings.py` file and add `'bootstrap3'` to your `INSTALLED_APPS` list.","cause":"The `bootstrap3` application is not included in your Django project's `INSTALLED_APPS` setting.","error":"django.core.exceptions.ImproperlyConfigured: The app 'bootstrap3' must be in INSTALLED_APPS."},{"fix":"Ensure `{% bootstrap_css %}` and `{% bootstrap_javascript %}` are present in your template's `<head>`. Use `{% bootstrap_form form %}` to render the entire form, or `{% bootstrap_field field %}` for individual fields, where `form` is your Django form instance.","cause":"Either Bootstrap 3 CSS/JavaScript is not loaded, or the Django form is not being rendered using the `django-bootstrap3` template tags.","error":"My Django form fields are not rendered with Bootstrap 3 styles, or form errors are not displayed correctly."}]}