Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use model error_messages when available #3435

Merged
merged 1 commit into from
Sep 24, 2015

Conversation

stianjensen
Copy link
Contributor

In the automatically applied UniqueValidator, use the error message from
error_messages defined in the model instead of the generic default
UniqueValidator message.

This fixes #2878.

In the automatically applied UniqueValidator, use the error message from
error_messages defined in the model instead of the generic default
UniqueValidator message.

This fixes encode#2878.
@tomchristie tomchristie added this to the 3.3.0 Release milestone Sep 23, 2015
@tomchristie
Copy link
Member

Seems reasonable.

tomchristie added a commit that referenced this pull request Sep 24, 2015
Use model error_messages when available
@tomchristie tomchristie merged commit 509c54d into encode:master Sep 24, 2015
@stianjensen stianjensen deleted the unique-error branch September 24, 2015 12:20
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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

django uses capfirst for verbose_name would such change be accepted?

Copy link
Member

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 of exactly where/what first tho?)

Copy link

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 it this?

Copy link
Member

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 doing capfirst(opts.verbose_name).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it filter OneToOneField?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error_messages on serializer fields should also be used by validators.
4 participants