add initial support for twitter bootstrap 2.0.1

This commit is contained in:
tzangms
2012-02-18 12:33:52 +08:00
parent 45d9917ecb
commit ab849748cc
3 changed files with 16 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
from distutils.version import StrictVersion from distutils.version import StrictVersion
VERSION = StrictVersion('0.2.0') VERSION = StrictVersion('2.0.1')

View File

@@ -7,12 +7,10 @@
{% endfor %} {% endfor %}
{% for field in form.visible_fields %} {% for field in form.visible_fields %}
<div class="clearfix{% if field.errors %} error{% endif %}"> <div class="control-group{% if field.errors %} error{% endif %}">
{% if field|is_checkbox %} {% if field|is_checkbox %}
<ul class="inputs-list"> <div class="controls">
<li> <label class="checkbox">
<div class="input">
<label>
{{ field }} <span>{{ field.label }}</span> {{ field }} <span>{{ field.label }}</span>
</label> </label>
@@ -21,16 +19,15 @@
{% endfor %} {% endfor %}
{% if field.help_text %} {% if field.help_text %}
<span class="help-block"> <p class="help-block">
{{ field.help_text }} {{ field.help_text }}
</span> </p>
{% endif %} {% endif %}
</div> </div>
</li>
</ul>
{% else %} {% else %}
{{ field.label_tag }} <div class="control-label">{{ field.label }}</div>
<div class="input">
<div class="controls">
{{ field }} {{ field }}
{% for error in field.errors %} {% for error in field.errors %}
@@ -38,9 +35,9 @@
{% endfor %} {% endfor %}
{% if field.help_text %} {% if field.help_text %}
<span class="help-block"> <p class="help-block">
{{ field.help_text }} {{ field.help_text }}
</span> </p>
{% endif %} {% endif %}
</div> </div>

View File

@@ -13,3 +13,8 @@ def bootstrap(form):
@register.filter @register.filter
def is_checkbox(field): def is_checkbox(field):
return field.field.widget.__class__.__name__.lower() == "checkboxinput" return field.field.widget.__class__.__name__.lower() == "checkboxinput"
@register.filter
def is_radio(field):
return field.field.widget.__class__.__name__.lower() == "radioselect"