Template tags and Usage

  1. Add to INSTALLED_APPS in your settings.py:
'bootstrap3',
  1. In your templates, load the bootstrap3 library and use the bootstrap_* tags:
{% load bootstrap3 %}

{# Load CSS and JavaScript #}

{% bootstrap_css %}
{% bootstrap_javascript %}

{# Display django.contrib.messages as Bootstrap alerts }
{% bootstrap_messages %}

{# Display a form #}

<form action="/url/to/submit/" method="post" class="form">
    {% csrf_token %}
    {% bootstrap_form form %}
    {% buttons %}
        <button type="submit" class="btn btn-primary">
            {% bootstrap_icon "star" %} Submit
        </button>
    {% endbuttons %}
</form>

The ``bootstrap3`` template tag library includes the following template tags:

Note

All the following examples it is understood that you have already loaded the bootstrap3 template tag library, placing the code below in the beginning that each template that bootstrap3 template tag library will be used:

{% load bootstrap3 %}

bootstrap_form

bootstrap3.templatetags.bootstrap3.bootstrap_form(*args, **kwargs)[source]

Render a form

Tag name:

bootstrap_form

Parameters:

args:
kwargs:

usage:

{% bootstrap_form form FIXTHIS %}

example:

{% bootstrap_form form FIXTHIS %}

bootstrap_formset

bootstrap3.templatetags.bootstrap3.bootstrap_formset(*args, **kwargs)[source]

Render a formset

Tag name:

bootstrap_formset

Parameters:

args:
kwargs:

usage:

{% bootstrap_formset formset FIXTHIS %}

example:

{% bootstrap_formset formset FIXTHIS %}

bootstrap_field

bootstrap3.templatetags.bootstrap3.bootstrap_field(*args, **kwargs)[source]

Render a field

Tag name:

bootstrap_field

Parameters:

args:
kwargs:

usage:

{% bootstrap_field form_field FIXTHIS %}

example:

{% bootstrap_form form_field FIXTHIS %}

bootstrap_label

bootstrap3.templatetags.bootstrap3.bootstrap_label(*args, **kwargs)[source]

Render a label

Tag name:

bootstrap_label

Parameters:

args:
kwargs:

usage:

{% bootstrap_label FIXTHIS %}

example:

{% bootstrap_label FIXTHIS %}

bootstrap_button

bootstrap3.templatetags.bootstrap3.bootstrap_button(*args, **kwargs)[source]

Render a button

Tag name:

bootstrap_button

Parameters:

args:
kwargs:

usage:

{% bootstrap_button FIXTHIS %}

example:

{% bootstrap_button FIXTHIS %}

bootstrap_icon

bootstrap3.templatetags.bootstrap3.bootstrap_icon(icon)[source]

Render an icon

Tag name:

bootstrap_icon

Parameters:

icon:icon name

usage:

{% bootstrap_icon "icon_name" %}

example:

{% bootstrap_icon "star" %}

buttons

bootstrap3.templatetags.bootstrap3.bootstrap_buttons(parser, token)[source]

Render buttons for form

Tag name:

bootstrap_buttons

Parameters:

parser:
token:

usage:

{% bootstrap_buttons FIXTHIS %}

example:

{% bootstrap_buttons FIXTHIS %}

bootstrap_messages

bootstrap3.templatetags.bootstrap3.bootstrap_messages(context, *args, **kwargs)[source]

Show django.contrib.messages Messages in Bootstrap alert containers

Tag name:

bootstrap_messages

Parameters:

context:
args:
kwargs:

usage:

{% bootstrap_messages FIXTHIS %}

example:

{% bootstrap_messages FIXTHIS %}

bootstrap_pagination

bootstrap3.templatetags.bootstrap3.bootstrap_pagination(page, **kwargs)[source]

Render pagination for a page

Tag name:

bootstrap_pagination

Parameters:

page:
kwargs:

usage:

{% bootstrap_pagination FIXTHIS %}

example:

{% bootstrap_pagination FIXTHIS %}

bootstrap_jquery_url

bootstrap3.templatetags.bootstrap3.bootstrap_jquery_url()[source]

Tag name:

bootstrap_jquery_url

Return the full url to jQuery file to use

Default value: //code.jquery.com/jquery.min.js

this value is configurable, see Settings section

usage:

{% bootstrap_jquery_url %}

example:

{% bootstrap_jquery_url %}

bootstrap_javascript_url

bootstrap3.templatetags.bootstrap3.bootstrap_javascript_url()[source]

Return the full url to FIXTHIS

Default value: None

this value is configurable, see Settings section

Tag name:

bootstrap_javascript_url

usage:

{% bootstrap_javascript_url %}

example:

{% bootstrap_javascript_url %}

bootstrap_css_url

bootstrap3.templatetags.bootstrap3.bootstrap_css_url()[source]

Return the full url to FIXTHIS

Default value: None

this value is configurable, see Settings section

Tag name:

bootstrap_css_url

usage:

{% bootstrap_css_url %}

example:

{% bootstrap_css_url %}

bootstrap_css

bootstrap3.templatetags.bootstrap3.bootstrap_css()[source]

Return HTML for Bootstrap CSS Adjust url in settings. If no url is returned, we don’t want this statement to return any HTML. This is intended behavior.

Default value: FIXTHIS

this value is configurable, see Settings section

Tag name:

bootstrap_css

usage:

{% bootstrap_css %}

example:

{% bootstrap_css %}

bootstrap_javascript

bootstrap3.templatetags.bootstrap3.bootstrap_javascript(jquery=False)[source]

Return HTML for Bootstrap JavaScript Adjust url in settings. If no url is returned, we don’t want this statement to return any HTML. This is intended behavior.

Default value: None

this value is configurable, see Settings section

Tag name:

bootstrap_javascript

Parameters:

jquery:True to include jquery FIXTHIS

usage:

{% bootstrap_javascript FIXTHIS %}

example:

{% bootstrap_javascript FIXTHIS %}