Skip to content

Instantly share code, notes, and snippets.

@christabor
Created July 2, 2014 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christabor/720c16ef57f2becfe5af to your computer and use it in GitHub Desktop.
Save christabor/720c16ef57f2becfe5af to your computer and use it in GitHub Desktop.
Apply widgets to many fields in django form easily and DRYly
class ...
class Meta:
_textarea = forms.Textarea(attrs={'cols': 40, 'rows': 5})
model = models.MyModel
widgets = {
'field1': _textarea,
'field2': _textarea,
'field3': _textarea,
'field4': _textarea,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment