mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Assert fields in exclude
are model fields
This commit is contained in:
parent
fcdef983b1
commit
d60ecfc498
|
@ -880,6 +880,10 @@ class ModelSerializer(Serializer):
|
||||||
exclude = getattr(self.Meta, 'exclude', None)
|
exclude = getattr(self.Meta, 'exclude', None)
|
||||||
if exclude is not None:
|
if exclude is not None:
|
||||||
for field_name in exclude:
|
for field_name in exclude:
|
||||||
|
assert field_name in fields, (
|
||||||
|
'The field in the `exclude` option must be a model field. Got %s.' %
|
||||||
|
field_name
|
||||||
|
)
|
||||||
fields.remove(field_name)
|
fields.remove(field_name)
|
||||||
|
|
||||||
# Determine the set of model fields, and the fields that they map to.
|
# Determine the set of model fields, and the fields that they map to.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user