add Meta.include which is the same as Meta.fields

'include' is the opposite of 'exclude', feels more natural.
This commit is contained in:
j0hnsmith 2017-01-28 15:23:39 +00:00
parent 220be31791
commit eee582af41

View File

@ -1027,7 +1027,7 @@ class ModelSerializer(Serializer):
set of fields, but also takes into account the `Meta.fields` or
`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)
if fields and fields != ALL_FIELDS and not isinstance(fields, (list, tuple)):