Skip to content

Commit 2c9750e

Browse files
author
Eric Hurst
committed
Use 'page_query_param' for pagination instead of hard coded page
*** What - Use self.page_query_param to determine the query parameter to use for pagination - Set the default page_query_param to 'page' - Freeze fake-factory version to 0.7.4 *** Why - Allow the use of different page query parameters to do pagination - The latest version of fake-factory is now depreciated: https://pypi.python.org/pypi/fake-factory/9999.9.9
1 parent c869f34 commit 2c9750e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

requirements-development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
pytest>=2.9.0,<3.0
33
pytest-django
44
pytest-factoryboy
5-
fake-factory
5+
fake-factory==0.7.4
66
tox
77
mock

rest_framework_json_api/pagination.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ class PageNumberPagination(PageNumberPagination):
1414
"""
1515

1616
page_size_query_param = 'page_size'
17+
page_query_param = 'page'
1718
max_page_size = 100
1819

1920
def build_link(self, index):
2021
if not index:
2122
return None
2223
url = self.request and self.request.build_absolute_uri() or ''
23-
return replace_query_param(url, 'page', index)
24+
return replace_query_param(url, self.page_query_param, index)
2425

2526
def get_paginated_response(self, data):
2627
next = None
@@ -95,4 +96,4 @@ def get_paginated_response(self, data):
9596
('next', self.get_next_link()),
9697
('prev', self.get_previous_link())
9798
])
98-
})
99+
})

0 commit comments

Comments
 (0)