mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 04:54:00 +03:00
class name added to unkown field error (#9019)
This commit is contained in:
parent
7658ffd71d
commit
5c3b6e496c
|
@ -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):
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user