Skip to content

Instantly share code, notes, and snippets.

@tomchristie
Created August 3, 2015 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomchristie/36d372204926de4f31a7 to your computer and use it in GitHub Desktop.
Save tomchristie/36d372204926de4f31a7 to your computer and use it in GitHub Desktop.
class InvoiceList(ManyRelatedField):
def __init__(self):
child = InvoiceSerializer()
super(InvoiceList, self).__init__()
def to_representation(self, iterable):
request = self.parent.context['request']
return [
self.child_relation.to_representation(value)
for value in iterable.filter(user=request.user)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment