Skip to content

Instantly share code, notes, and snippets.

@jacoor
Created March 5, 2014 15:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacoor/9369641 to your computer and use it in GitHub Desktop.
Save jacoor/9369641 to your computer and use it in GitHub Desktop.
additional data for listApiView for django.rest.framework
class TransactionsList(ListAPIView):
"""
List all transactions for currently logged in user, paginated by 25
page -- page number
ordering -- yoddle_amount, created, yoddle_description, reverse order ie. -yoddle_amount
"""
model = Transaction
serializer_class = TransactionSerializer
paginate_by = 25
allow_empty = True
filter_backends = (filters.OrderingFilter,)
def get_queryset(self):
return self.request.user.transactions.all()
"""
Concrete view for listing a queryset.
"""
def get(self, request, *args, **kwargs):
response = super(TransactionsList, self).get(request, *args, **kwargs)
response.data['variable'] = 'data'
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment