Use verbose_name instead of object_name in error messages by sassanh · Pull Request #4299 · encode/django-rest-framework (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation8 Commits3 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Note: Before submitting this pull request, please review our contributing guidelines.
Description
It should use verbose_name
, not object_name
, took me 2 hours to find out why parts of error were not translated as I didn't expect it to happen in drf.
Yup this looks good, thanks!
Note that there's a test case that also needs to be updated as part of this pull request.
tests/test_validators.py:80: in test_is_not_unique
assert serializer.errors == {'username': ['UniquenessModel with this username already exists.']}
E AssertionError: assert {'username': ...ady exists.']} == {'username': [...ady exists.']}
E Differing items:
E {'username': ['uniqueness model with this username already exists.']} != {'username': ['UniquenessModel with this username already exists.']}
I'll upgrade the test, could you please review my 2 commits and tell me which one is the right one?
Current coverage is 91.19% (diff: 100%)
@@ master #4299 diff @@
Files 52 52
Lines 5776 5781 +5
Methods 0 0
Messages 0 0
Branches 0 0
- Hits 5267 5272 +5
Misses 509 509
Partials 0 0
Powered by Codecov. Last update 0f61c9e...09d5f85
I'll upgrade the test, could you please review my 2 commits and tell me which one is the right one?
Sorry, could you be more explicit?
The change in the PR looks correct, as it currently stands.
@@ -59,7 +59,7 @@ def get_detail_view_name(model): |
---|
""" |
return '%(model_name)s-detail' % { |
'app_label': model._meta.app_label, |
'model_name': model._meta.verbose_name.lower() |
'model_name': model._meta.object_name.lower() |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomchristie is it correct the way it is or should I convert this object_name
to verbose_name
too?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should remain as object_name
, as you currently have it.
tomchristie changed the title
use verbose_name instead of object_name in field_mapping Use verbose_name instead of object_name in error messages
helgi added a commit to helgi/controller that referenced this pull request
helgi added a commit to helgi/controller that referenced this pull request