Template tags and Usage¶
- Add to INSTALLED_APPS in your
settings.py:
'bootstrap3',
- In your templates, load the
bootstrap3library and use thebootstrap_*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¶
Render a form
Tag name:
bootstrap_formParameters:
args: kwargs: usage:
{% bootstrap_form form FIXTHIS %}example:
{% bootstrap_form form FIXTHIS %}
bootstrap_formset¶
Render a formset
Tag name:
bootstrap_formsetParameters:
args: kwargs: usage:
{% bootstrap_formset formset FIXTHIS %}example:
{% bootstrap_formset formset FIXTHIS %}
bootstrap_field¶
Render a field
Tag name:
bootstrap_fieldParameters:
args: kwargs: usage:
{% bootstrap_field form_field FIXTHIS %}example:
{% bootstrap_form form_field FIXTHIS %}
bootstrap_label¶
Render a label
Tag name:
bootstrap_labelParameters:
args: kwargs: usage:
{% bootstrap_label FIXTHIS %}example:
{% bootstrap_label FIXTHIS %}
bootstrap_button¶
Render a button
Tag name:
bootstrap_buttonParameters:
args: kwargs: usage:
{% bootstrap_button FIXTHIS %}example:
{% bootstrap_button FIXTHIS %}
bootstrap_icon¶
Render an icon
Tag name:
bootstrap_iconParameters:
icon: icon name usage:
{% bootstrap_icon "icon_name" %}example:
{% bootstrap_icon "star" %}
buttons¶
Render buttons for form
Tag name:
bootstrap_buttonsParameters:
parser: token: usage:
{% bootstrap_buttons FIXTHIS %}example:
{% bootstrap_buttons FIXTHIS %}
bootstrap_messages¶
Show django.contrib.messages Messages in Bootstrap alert containers
Tag name:
bootstrap_messagesParameters:
context: args: kwargs: usage:
{% bootstrap_messages FIXTHIS %}example:
{% bootstrap_messages FIXTHIS %}
bootstrap_pagination¶
Render pagination for a page
Tag name:
bootstrap_paginationParameters:
page: kwargs: usage:
{% bootstrap_pagination FIXTHIS %}example:
{% bootstrap_pagination FIXTHIS %}
bootstrap_jquery_url¶
Tag name:
bootstrap_jquery_urlReturn the full url to jQuery file to use
Default value:
//code.jquery.com/jquery.min.jsthis value is configurable, see Settings section
usage:
{% bootstrap_jquery_url %}example:
{% bootstrap_jquery_url %}
bootstrap_javascript_url¶
Return the full url to FIXTHIS
Default value:
Nonethis value is configurable, see Settings section
Tag name:
bootstrap_javascript_urlusage:
{% bootstrap_javascript_url %}example:
{% bootstrap_javascript_url %}
bootstrap_css_url¶
Return the full url to FIXTHIS
Default value:
Nonethis value is configurable, see Settings section
Tag name:
bootstrap_css_urlusage:
{% bootstrap_css_url %}example:
{% bootstrap_css_url %}
bootstrap_css¶
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:
FIXTHISthis value is configurable, see Settings section
Tag name:
bootstrap_cssusage:
{% bootstrap_css %}example:
{% bootstrap_css %}
bootstrap_javascript¶
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:
Nonethis value is configurable, see Settings section
Tag name:
bootstrap_javascriptParameters:
jquery: True to include jquery FIXTHIS usage:
{% bootstrap_javascript FIXTHIS %}example:
{% bootstrap_javascript FIXTHIS %}