Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Use model error_messages when available#3435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In the automatically applied UniqueValidator, use the error message fromerror_messages defined in the model instead of the generic defaultUniqueValidator message.Thisfixesencode#2878.
lovelydinosaur commentedSep 23, 2015
Seems reasonable. |
Use model error_messages when available
| unique_error_message=model_field.error_messages.get('unique',None) | ||
| ifunique_error_message: | ||
| unique_error_message=unique_error_message% { | ||
| 'model_name':model_field.model._meta.object_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
django usescapfirst forverbose_name would such change be accepted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Most probably yup! (Could you point out an example ofexactly where/what first tho?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm not sure what you would like to see. Is itthis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Perfect, yup. If you do choose to submit a fix for this it'll also be worth double checking if there's any other errors messages where we should also be doingcapfirst(opts.verbose_name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
can it filter OneToOneField?
In the automatically applied UniqueValidator, use the error message from
error_messages defined in the model instead of the generic default
UniqueValidator message.
Thisfixes#2878.