Skip to content

Commit

Permalink
add has_more in pagination result #89
Browse files Browse the repository at this point in the history
  • Loading branch information
sweemeng committed Jan 25, 2016
1 parent 7b294a5 commit 8f097c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils.py
Expand Up @@ -12,12 +12,17 @@ def paginate_queryset(self, queryset, request, view=None):
return result

def get_paginated_response(self, data):
if self.get_next_link():
has_more = True
else:
has_more = False
return Response(OrderedDict([
('page', int(self.page_number)),
('total', self.page.paginator.count),
('next', self.get_next_link()),
('previous', self.get_previous_link()),
('results', data),
('per_page', self.page_size),
('num_pages', self.page.paginator.num_pages)
('num_pages', self.page.paginator.num_pages),
('has_more', has_more)
]))

0 comments on commit 8f097c8

Please sign in to comment.