Django Bootstrap3

26.1 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

{% load bootstrap3 %}
<!DOCTYPE html>
<html>
<head>
    <title>Django Bootstrap3 Example</title>
    {% bootstrap_css %}
    {% bootstrap_javascript %}
    <style>
        .container { margin-top: 20px; }
    </style>
</head>
<body>
    <div class="container">
        <h1>Contact Us</h1>
        {% bootstrap_messages %}
        <form action="" method="post" class="form">
            {% csrf_token %}
            {% bootstrap_form form layout='horizontal' %}
            {% buttons submit='Submit' %}
                <button type="submit" class="btn btn-primary">
                    <span class="glyphicon glyphicon-envelope"></span> Submit
                </button>
            {% endbuttons %}
        </form>
    </div>
</body>
</html>

view raw JSON →