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

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy