Commit d60ecfc4 by Tymur Maryokhin

Assert fields in `exclude` are model fields

parent fcdef983
......@@ -880,6 +880,10 @@ class ModelSerializer(Serializer):
exclude = getattr(self.Meta, 'exclude', None)
if exclude is not None:
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)
# Determine the set of model fields, and the fields that they map to.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment