initial commit
This commit is contained in:
commit
331d6066ef
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.pyc
|
5
README
Normal file
5
README
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Generate twitter-bootstrap form output for django form
|
||||||
|
|
||||||
|
{% load bootstrap %}
|
||||||
|
|
||||||
|
{{ form|bootstrape }}
|
0
__init__.py
Normal file
0
__init__.py
Normal file
3
models.py
Normal file
3
models.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
27
templates/bootstrap_form/form.html
Normal file
27
templates/bootstrap_form/form.html
Normal 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
0
templatetags/__init__.py
Normal file
15
templatetags/bootstrap.py
Normal file
15
templatetags/bootstrap.py
Normal 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
16
tests.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user