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.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -193,7 +193,15 @@ def get_field_kwargs(field_name, model_field): | ||
| ] | ||
| if getattr(model_field, 'unique', False): | ||
| unique_error_message = model_field.error_messages.get('unique', None) | ||
| if unique_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 commentThe reason will be displayed to describe this comment to others.Learn more. django usescapfirst for Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others.Learn more. I'm not sure what you would like to see. Is itthis? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. can it filter OneToOneField? | ||
| 'field_label': model_field.verbose_name | ||
| } | ||
| validator = UniqueValidator( | ||
| queryset=model_field.model._default_manager, | ||
| message=unique_error_message) | ||
| validator_kwarg.append(validator) | ||
| if validator_kwarg: | ||