Created
December 7, 2017 03:46
-
-
Save bhavaniravi/8a03783b36500d098af30068d0291007 to your computer and use it in GitHub Desktop.
Django configure form field with bootstrap form-elements
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
def configure_fields(fields): | |
""" | |
Configures form field with bootstrap style | |
Input forms fields | |
Output formatted form fields | |
""" | |
for field in fields: | |
if isinstance(fields[field].widget, Textarea): | |
fields[field].widget.attrs['rows'] = '3' | |
fields[field].widget.attrs['class'] = 'form-control' | |
return fields |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment