Created
March 5, 2014 15:37
-
-
Save jacoor/9369641 to your computer and use it in GitHub Desktop.
additional data for listApiView for django.rest.framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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