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:
Sassan Haradji 2016-07-26 18:42:51 +04:30 committed by Tom Christie
parent b63099084f
commit f0f61aa077
2 changed files with 2 additions and 2 deletions

View File

@ -220,7 +220,7 @@ def get_field_kwargs(field_name, model_field):
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,
'model_name': model_field.model._meta.verbose_name,
'field_label': model_field.verbose_name
}
validator = UniqueValidator(

View File

@ -77,7 +77,7 @@ class TestUniquenessValidation(TestCase):
data = {'username': 'existing'}
serializer = UniquenessSerializer(data=data)
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):
data = {'username': 'other'}