mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
This commit is contained in:
commit
c5691cca0e
|
@ -679,7 +679,7 @@ class PaginatorMixin(object):
|
|||
Constructs a url used for getting the next/previous urls
|
||||
"""
|
||||
url = URLObject.parse(self.request.get_full_path())
|
||||
url = url.add_query_param('page', page_number)
|
||||
url = url.set_query_param('page', page_number)
|
||||
|
||||
limit = self.get_limit()
|
||||
if limit != self.limit:
|
||||
|
|
|
@ -280,3 +280,12 @@ class TestPagination(TestCase):
|
|||
self.assertTrue('foo=bar' in content['next'])
|
||||
self.assertTrue('another=something' in content['next'])
|
||||
self.assertTrue('page=2' in content['next'])
|
||||
|
||||
def test_duplicate_parameters_are_not_created(self):
|
||||
""" Regression: ensure duplicate "page" parameters are not added to
|
||||
paginated URLs. So page 1 should contain ?page=2, not ?page=1&page=2 """
|
||||
request = self.req.get('/paginator/?page=1')
|
||||
response = MockPaginatorView.as_view()(request)
|
||||
content = json.loads(response.content)
|
||||
self.assertTrue('page=2' in content['next'])
|
||||
self.assertFalse('page=1' in content['next'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user