Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
5b7c8658
Commit
5b7c8658
authored
Feb 07, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #156 from j4mie/duplicate-page-param
Ensure duplicate "page" parameters are not created
parents
0f49f9b2
76a7d358
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletions
+10
-1
djangorestframework/mixins.py
+1
-1
djangorestframework/tests/mixins.py
+9
-0
No files found.
djangorestframework/mixins.py
View file @
5b7c8658
...
...
@@ -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
:
...
...
djangorestframework/tests/mixins.py
View file @
5b7c8658
...
...
@@ -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'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment