mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
use verbose_name instead of object_name in field_mapping (#4299)
* use verbose_name instead of object_name in error messages
This commit is contained in:
parent
b63099084f
commit
f0f61aa077
|
@ -220,7 +220,7 @@ def get_field_kwargs(field_name, model_field):
|
||||||
unique_error_message = model_field.error_messages.get('unique', None)
|
unique_error_message = model_field.error_messages.get('unique', None)
|
||||||
if unique_error_message:
|
if unique_error_message:
|
||||||
unique_error_message = unique_error_message % {
|
unique_error_message = unique_error_message % {
|
||||||
'model_name': model_field.model._meta.object_name,
|
'model_name': model_field.model._meta.verbose_name,
|
||||||
'field_label': model_field.verbose_name
|
'field_label': model_field.verbose_name
|
||||||
}
|
}
|
||||||
validator = UniqueValidator(
|
validator = UniqueValidator(
|
||||||
|
|
|
@ -77,7 +77,7 @@ class TestUniquenessValidation(TestCase):
|
||||||
data = {'username': 'existing'}
|
data = {'username': 'existing'}
|
||||||
serializer = UniquenessSerializer(data=data)
|
serializer = UniquenessSerializer(data=data)
|
||||||
assert not serializer.is_valid()
|
assert not serializer.is_valid()
|
||||||
assert serializer.errors == {'username': ['UniquenessModel with this username already exists.']}
|
assert serializer.errors == {'username': ['uniqueness model with this username already exists.']}
|
||||||
|
|
||||||
def test_is_unique(self):
|
def test_is_unique(self):
|
||||||
data = {'username': 'other'}
|
data = {'username': 'other'}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user