mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Update pagination.py
Allow User to add extra fields to data before sending it to HTTP Response
This commit is contained in:
parent
b069b0d33a
commit
dd4fdcc418
|
@ -225,13 +225,16 @@ class PageNumberPagination(BasePagination):
|
|||
self.request = request
|
||||
return list(self.page)
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
return Response(OrderedDict([
|
||||
def get_paginated_dictionary(self, data):
|
||||
return OrderedDict([
|
||||
('count', self.page.paginator.count),
|
||||
('next', self.get_next_link()),
|
||||
('previous', self.get_previous_link()),
|
||||
('results', data)
|
||||
]))
|
||||
])
|
||||
|
||||
def get_paginated_response(self, data, extra_fields={}):
|
||||
return Response(self.get_paginated_dictionary(data).update(extra_fields))
|
||||
|
||||
def get_page_size(self, request):
|
||||
if self.page_size_query_param:
|
||||
|
|
Loading…
Reference in New Issue
Block a user