django-bootstrap-forms is a Django app that provides Twitter bootstrap ready Django forms.
Installation
1. Install using pip:
pip install -e git+git://github.com/earle/django-bootstrap.git#egg=bootstrap
2. Add to INSTALLED_APPS:
'bootstrap',
Usage
from bootstrap.forms import BootstrapForm, Fieldset
class LoginForm(BootstrapForm):
class Meta:
layout = (
Fieldset("Please Login", "username", "password", ),
)
username = forms.CharField(max_length=100)
password = forms.CharField(widget=forms.PasswordInput(), max_length=100)
If you want to use the Bootstrap Form wrapper on a built-in form, such as those in `django.contrib.auth.forms` then you can use the mixin class.
from django.contrib.auth.forms import PasswordChangeForm
from bootstrap.forms import BootstrapMixin, Fieldset
class BootstrapPasswordChangeForm(BootstrapMixin, PasswordChangeForm):
class Meta:
layout = (
Fieldset("Change your password",
"old_password", "new_password1", "new_password2"),
When using the mixin directly it must be the first class your form inherits from.
Template Usage
< form action="/login/" method="post" class="form-horizontal" >
{{ form }}
< div class="form-actions" >
< button type="submit" class="btn btn-primary" >Login< /button >
< /div >
< /form >
Requirements:
- Python
- Django
Comments not found