mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
add Meta.include which is the same as Meta.fields
'include' is the opposite of 'exclude', feels more natural.
This commit is contained in:
parent
220be31791
commit
eee582af41
|
@ -1027,7 +1027,7 @@ class ModelSerializer(Serializer):
|
||||||
set of fields, but also takes into account the `Meta.fields` or
|
set of fields, but also takes into account the `Meta.fields` or
|
||||||
`Meta.exclude` options if they have been specified.
|
`Meta.exclude` options if they have been specified.
|
||||||
"""
|
"""
|
||||||
fields = getattr(self.Meta, 'fields', None)
|
fields = getattr(self.Meta, 'fields', getattr(self.Meta, 'include', None))
|
||||||
exclude = getattr(self.Meta, 'exclude', None)
|
exclude = getattr(self.Meta, 'exclude', None)
|
||||||
|
|
||||||
if fields and fields != ALL_FIELDS and not isinstance(fields, (list, tuple)):
|
if fields and fields != ALL_FIELDS and not isinstance(fields, (list, tuple)):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user