Skip to content

Instantly share code, notes, and snippets.

@lovelydinosaur
Created August 3, 2015 14:38
Show Gist options
  • Select an option

  • Save lovelydinosaur/36d372204926de4f31a7 to your computer and use it in GitHub Desktop.

Select an option

Save lovelydinosaur/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