Created
March 27, 2017 21:12
-
-
Save MandarGogate/12047769e0080dd46ca0495148642855 to your computer and use it in GitHub Desktop.
Overriding Django Model Forms for labels, help text and error message
This file contains hidden or 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 AuthorForm(ModelForm): | |
class Meta: | |
model = Author | |
fields = ('name', 'title', 'birth_date') | |
labels = { | |
'name': _('Writer'), | |
} | |
help_texts = { | |
'name': _('Some useful help text.'), | |
} | |
error_messages = { | |
'name': { | |
'max_length': _("This writer's name is too long."), | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment