Welcome to django-bootstrap3’s documentation!

Contents:

django-bootstrap3

https://travis-ci.org/dyve/django-bootstrap3.png?branch=master https://badge.fury.io/py/django-bootstrap3.png https://pypip.in/d/django-bootstrap3/badge.png

Bootstrap support for Django projects

Documentation

The full documentation is at http://django-bootstrap3.rtfd.org.

Quickstart

  1. Install using pip:

    pip install django-bootstrap3

    Alternatively, you can install download or clone this repo and call pip install -e ..

  2. Add to INSTALLED_APPS in your settings.py:

    ‘bootstrap3’,

  3. 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>

Features

  • TODO

Requirements

  • Python 2.6, 2.7 and 3.3
  • Django >= 1.4

Contributions and pull requests for other Django and Python versions are welcome.

Bugs and requests

If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.

https://github.com/dyve/django-bootstrap3/issues

License

You can use this under Apache 2.0. See LICENSE file for details.

Author

My name is Dylan Verheul, you can reach me at <dylan@dyve.net> or [follow me on Twitter][1].

[1]: http://twitter.com/dyve

Installation

At the command line:

$ easy_install django-bootstrap3

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv django-bootstrap3
$ pip install django-bootstrap3

Settings

The django-bootstrap3 has some pre-configured settings.

They can be modified by adding a dict variable called BOOTSTRAP3 in your settings.py and customizing the values ​​you want;

The BOOTSTRAP3 dict variable is configured by default to the following values​​:

BOOTSTRAP3 = {
    'jquery_url': '//code.jquery.com/jquery.min.js',
    'base_url': '//netdna.bootstrapcdn.com/bootstrap/3.0.3/',
    'css_url': None,
    'theme_url': None,
    'javascript_url': None,
    'horizontal_label_class': 'col-md-2',
    'horizontal_field_class': 'col-md-4',
}

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 %}

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/dyve/django-bootstrap3/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.

Write Documentation

django-bootstrap3 could always use more documentation, whether as part of the official django-bootstrap3 docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/dyve/django-bootstrap3/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up django-bootstrap3 for local development.

  1. Fork the django-bootstrap3 repo on GitHub.

  2. Clone your fork locally:

    $ git clone https://github.com/your_username_here/django-bootstrap3.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv django-bootstrap3
    $ cd django-bootstrap3/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

Now you can make your changes locally.

5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

$ flake8 bootstrap3 tests
$ python setup.py test
$ tox

To get flake8 and tox, just pip install them into your virtualenv.

  1. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  2. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/dyve/django-bootstrap3/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_bootstrap3

Credits

Development Lead

Contributors

Allard Stijnman <a.g.stijnman@gmail.com> Austin Whittier <austin.whitt@gmail.com> Caio Ariede <caio.ariede@gmail.com> Fabio C. Barrionuevo da Luz <bnafta@gmail.com> Jay Pipes <jaypipes@gmail.com> Jonas Hagstedt <hagstedt@gmail.com> Jordan Starcher <jstarcher@gmail.com> Juan Carlos <juancarlospaco@gmail.com> Markus Holtermann <info@markusholtermann.eu> Nick S <nsmith448@gmail.com> Owais Lone <loneowais@gmail.com> Richard Hajdu <tuskone16@gmail.com> pmav99 <pmav99@users.noreply.github.com>

History

2.5.6 (2014-01-23)

  • project refactored
  • added skeleton for creating documentation to fix issue #30