Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created August 19, 2013 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattdeboard/6275144 to your computer and use it in GitHub Desktop.
Save mattdeboard/6275144 to your computer and use it in GitHub Desktop.
class Meta:
queryset = Item.objects.prefetch_related('components_set').all()
def dehydrate(self, bundle):
# ...
bundle.data['quantity'] = bundle.obj.components_set.count()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment