Created
July 2, 2014 23:20
-
-
Save christabor/720c16ef57f2becfe5af to your computer and use it in GitHub Desktop.
Apply widgets to many fields in django form easily and DRYly
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 ... | |
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