Fixed #20000 -- Allowed ModelForm meta overrides for labels, help_texts and error_messages #1251

Closed
wants to merge 2 commits into from

2 participants

@timgraham
Django member

No description provided.

@jezdez jezdez commented on the diff Jun 7, 2013
docs/topics/forms/modelforms.txt
+
+Similarly, you can specify the ``labels``, ``help_texts`` and ``error_messages``
+attributes of the inner ``Meta`` class if you want to further customize a field.
+
+For example if you wanted to customize the wording of all user facing strings for
+the ``name`` field::
+
+ class AuthorForm(ModelForm):
+ class Meta:
+ model = Author
+ fields = ('name', 'title', 'birth_date')
+ labels = {
+ 'name': 'Writer',
+ }
+ help_texts = {
+ 'name': 'Some useful help text.',
@jezdez
Django member
jezdez added a note Jun 7, 2013

This should be translatable to be a good example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jezdez jezdez commented on the diff Jun 7, 2013
docs/topics/forms/modelforms.txt
+For example if you wanted to customize the wording of all user facing strings for
+the ``name`` field::
+
+ 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.",
@jezdez
Django member
jezdez added a note Jun 7, 2013

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham timgraham closed this Jun 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment