Skip to content

Instantly share code, notes, and snippets.

@bhavaniravi
Created December 7, 2017 03:46
Show Gist options
  • Save bhavaniravi/8a03783b36500d098af30068d0291007 to your computer and use it in GitHub Desktop.
Save bhavaniravi/8a03783b36500d098af30068d0291007 to your computer and use it in GitHub Desktop.
Django configure form field with bootstrap form-elements
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