Skip to content

Commit

Permalink
Merge pull request #2319 from maryokhin/master
Browse files Browse the repository at this point in the history
Assert fields in `exclude` are model fields
  • Loading branch information
tomchristie committed Dec 18, 2014
2 parents 7105c13 + d60ecfc commit e0096fe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,10 @@ def get_fields(self):
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.
Expand Down

0 comments on commit e0096fe

Please sign in to comment.