Skip to content

Instantly share code, notes, and snippets.

@MandarGogate
Created March 27, 2017 21:12
Show Gist options
  • Save MandarGogate/12047769e0080dd46ca0495148642855 to your computer and use it in GitHub Desktop.
Save MandarGogate/12047769e0080dd46ca0495148642855 to your computer and use it in GitHub Desktop.
Overriding Django Model Forms for labels, help text and error message
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