Skip to content

Commit e0096fe

Browse files
committed
Merge pull request #2319 from maryokhin/master
Assert fields in `exclude` are model fields
2 parents 7105c13 + d60ecfc commit e0096fe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rest_framework/serializers.py

+4
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)