Skip to content

Instantly share code, notes, and snippets.

@donspaulding
Created June 21, 2013 17:33
Show Gist options
  • Save donspaulding/5832861 to your computer and use it in GitHub Desktop.
Save donspaulding/5832861 to your computer and use it in GitHub Desktop.
def partially_nested(serializer, include_fields=None, exclude_fields=None):
partial_fields = set(include_fields or []) - set(exclude_fields or [])
serializer.opts.exclude = tuple(
set(serializer.get_fields()) - set(partial_fields)
)
serializer.fields = serializer.get_fields()
return serializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment