class name added to unkown field error (#9019)

This commit is contained in:
Amin Aminian 2023-07-25 09:51:25 +02:00 committed by GitHub
parent 7658ffd71d
commit 5c3b6e496c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -1372,8 +1372,8 @@ class ModelSerializer(Serializer):
Raise an error on any unknown fields. Raise an error on any unknown fields.
""" """
raise ImproperlyConfigured( raise ImproperlyConfigured(
'Field name `%s` is not valid for model `%s`.' % 'Field name `%s` is not valid for model `%s` in `%s.%s`.' %
(field_name, model_class.__name__) (field_name, model_class.__name__, self.__class__.__module__, self.__class__.__name__)
) )
def include_extra_kwargs(self, kwargs, extra_kwargs): def include_extra_kwargs(self, kwargs, extra_kwargs):

View File

@ -315,7 +315,8 @@ class TestRegularFieldMappings(TestCase):
model = RegularFieldsModel model = RegularFieldsModel
fields = ('auto_field', 'invalid') fields = ('auto_field', 'invalid')
expected = 'Field name `invalid` is not valid for model `RegularFieldsModel`.' expected = 'Field name `invalid` is not valid for model `RegularFieldsModel` ' \
'in `tests.test_model_serializer.TestSerializer`.'
with self.assertRaisesMessage(ImproperlyConfigured, expected): with self.assertRaisesMessage(ImproperlyConfigured, expected):
TestSerializer().fields TestSerializer().fields