Coder Social home page Coder Social logo

williamren / django-bootstrap2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emidln/django-bootstrap2

0.0 2.0 0.0 208 KB

A reusable Django application to quickly integrate the Bootstrap toolkit from Twitter.

License: Other

Python 100.00%

django-bootstrap2's Introduction

Django Bootstrap2 with Twitter Bootstrap v2.3.2

Bootstrapped is a reusable Django application to quickly integrate the Bootstrap toolkit from Twitter. It's a collection of the bootstrap toolkit files and template tags to display them.

This application depends on django.contrib.staticfiles.

No files from Twitter's Bootstrap toolkit have been modified and retain their Apache 2.0 license.

  • Note: This app only works on Django 1.3 and newer.

Installation

pip install git+git://github.com/benjschiller/django-bootstrap2.git

Configuration

  1. Add the bootstrap2 directory to your Python path.
  2. Ensure django.contrib.staticfiles is added to your INSTALLED_APPS setting.
  3. Ensure django.contrib.staticfiles is configured properly.
  4. Add bootstrap2 to your INSTALLED_APPS setting.
  5. Run manage.py collectstatic to copy the Twitter Bootstrap toolkit files to your static directory.
  6. Ensure you added {% load bootstrap_tags %} before use tags in templates.

Template Usage

This application exposes a few template tags for including the Bootstrap toolkit files.

Load the template tags before usage:

{% load bootstrap_tags %}

`bootstrap_css`

This tag renders the link tag for the bootstrap.min.css file. It will render the un-minified version if settings.TEMPLATE_DEBUG is set to True:

{% bootstrap_css %}

Output:

<link rel="stylesheet" href="/static/bootstrap.css">

`bootstrap_js`

The Bootstrap toolkit provides some javascript love (http://bootstrap.io/Demo/Javascript) that is compatible with jQuery and Ender. This tag renders the appropriate script include tag for each plugin defined. The tag does not include jQuery or Ender, that's up to you:

{% bootstrap_js modal alerts dropdown %}

Output:

<script src="YOUR_STATIC_URLjs/bootstrap-alerts.js"></script>
<script src="YOUR_STATIC_URLjs/bootstrap-dropdown.js"></script>
<script src="YOUR_STATIC_URLjs/bootstrap-modal.js"></script>
  • Note: The popover javascript file has a dependency on the twipsy file. If you add popover to the list and forget to add twipsy, the tag will do it for you.

Alternatively, you may just want to include all of the scripts. If so, just use all for the tag arguments:

{% bootstrap_js all %}

Forms

To style forms do something like:

<form method="POST" action="">{% csrf_token %}
{{ form|as_bootstrap }}
<div class="actions"><button type="submit" class="btn primary">Submit</button></div>
</form>

django-bootstrap2's People

Contributors

benjschiller avatar

Watchers

william avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.