Last active
December 20, 2015 17:59
-
-
Save aherok/6172929 to your computer and use it in GitHub Desktop.
BootstrappedMixin for form - adds Bootstrap3.0 classes & placeholder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BootstrappedMixin(object): | |
def __init__(self, *args, **kwargs): | |
super(BootstrappedMixin, self).__init__(*args, **kwargs) | |
for field_name in self.fields: | |
field = self.fields.get(field_name) | |
attrs = {'class': 'form-control'} | |
if field and isinstance(field.widget, forms.TextInput): | |
attrs.update({'placeholder': field.label}) | |
field.widget.attrs = attrs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment