initial commit

This commit is contained in:
tzangms 2011-08-21 09:07:02 -07:00
commit 331d6066ef
9 changed files with 68 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.pyc

5
README Normal file
View File

@ -0,0 +1,5 @@
Generate twitter-bootstrap form output for django form
{% load bootstrap %}
{{ form|bootstrape }}

0
__init__.py Normal file
View File

3
models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@ -0,0 +1,27 @@
{% load bootstrap %}
{% for field in form %}
<div class="clearfix {% if field.errors %}error{% endif %}">
{% if field|is_checkbox %}
<ul class="inputs-list">
<li>
<div class="input">
<label>
{{ field }} <span>{{ field.label }}</span>
</label>
</div>
</li>
</ul>
{% else %}
{{ field.label_tag }}
<div class="input">
{{ field }}
{% if field.errors %}
{% for error in field.errors %}
<span class="help-inline">{{ error }}</span>
{% endfor %}
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}

0
templatetags/__init__.py Normal file
View File

15
templatetags/bootstrap.py Normal file
View File

@ -0,0 +1,15 @@
from django.template import Context
from django.template.loader import get_template
from django import template
register = template.Library()
@register.filter
def bootstrap(form):
template = get_template("bootstrap_form/form.html")
context = Context({'form': form})
return template.render(context)
@register.filter
def is_checkbox(field):
return field.field.widget.__class__.__name__.lower() == "checkboxinput"

16
tests.py Normal file
View File

@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)

1
views.py Normal file
View File

@ -0,0 +1 @@
# Create your views here.