mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 21:10:13 +03:00
Merge ff3c8187a6
into d872c8e2e7
This commit is contained in:
commit
5f8b73d8c9
|
@ -974,10 +974,7 @@ class ModelSerializer(Serializer):
|
||||||
kwargs = get_url_kwargs(model)
|
kwargs = get_url_kwargs(model)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ImproperlyConfigured(
|
field_cls, kwargs = self.get_extra_field(field_name, model)
|
||||||
'Field name `%s` is not valid for model `%s`.' %
|
|
||||||
(field_name, model.__class__.__name__)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check that any fields declared on the class are
|
# Check that any fields declared on the class are
|
||||||
# also explicitly included in `Meta.fields`.
|
# also explicitly included in `Meta.fields`.
|
||||||
|
@ -1013,6 +1010,12 @@ class ModelSerializer(Serializer):
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_extra_field(self, field_name, model):
|
||||||
|
raise ImproperlyConfigured(
|
||||||
|
'Field name `%s` is not valid for model `%s`.' %
|
||||||
|
(field_name, model.__class__.__name__)
|
||||||
|
)
|
||||||
|
|
||||||
def _include_additional_options(self, extra_kwargs):
|
def _include_additional_options(self, extra_kwargs):
|
||||||
read_only_fields = getattr(self.Meta, 'read_only_fields', None)
|
read_only_fields = getattr(self.Meta, 'read_only_fields', None)
|
||||||
if read_only_fields is not None:
|
if read_only_fields is not None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user