mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 21:10:13 +03:00
Merge b5e8187e5d
into 15024f3f07
This commit is contained in:
commit
d3cc0befcf
|
@ -1074,6 +1074,11 @@ For example, if you wanted to be able to set which fields should be used by a se
|
||||||
# Drop any fields that are not specified in the `fields` argument.
|
# Drop any fields that are not specified in the `fields` argument.
|
||||||
allowed = set(fields)
|
allowed = set(fields)
|
||||||
existing = set(self.fields.keys())
|
existing = set(self.fields.keys())
|
||||||
|
|
||||||
|
# Catch fields that don't exist
|
||||||
|
non_existing = allowed - existing
|
||||||
|
assert len(non_existing) == 0, 'Invalid fields: {}'.format(non_existing)
|
||||||
|
|
||||||
for field_name in existing - allowed:
|
for field_name in existing - allowed:
|
||||||
self.fields.pop(field_name)
|
self.fields.pop(field_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user