Skip to content

Commit d60ecfc

Browse files
committed
Assert fields in exclude are model fields
1 parent fcdef98 commit d60ecfc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rest_framework/serializers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,10 @@ def get_fields(self):
880880
exclude = getattr(self.Meta, 'exclude', None)
881881
if exclude is not None:
882882
for field_name in exclude:
883+
assert field_name in fields, (
884+
'The field in the `exclude` option must be a model field. Got %s.' %
885+
field_name
886+
)
883887
fields.remove(field_name)
884888

885889
# Determine the set of model fields, and the fields that they map to.

0 commit comments

Comments
 (0)