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
d1ce9d39
Commit
d1ce9d39
authored
Jan 21, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More consistent comment style.
parent
dea4a45e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
djangorestframework/mixins.py
+12
-4
No files found.
djangorestframework/mixins.py
View file @
d1ce9d39
...
@@ -689,7 +689,9 @@ class PaginatorMixin(object):
...
@@ -689,7 +689,9 @@ class PaginatorMixin(object):
limit
=
20
limit
=
20
def
get_limit
(
self
):
def
get_limit
(
self
):
""" Helper method to determine what the `limit` should be """
"""
Helper method to determine what the `limit` should be
"""
try
:
try
:
limit
=
int
(
self
.
request
.
GET
.
get
(
'limit'
,
self
.
limit
))
limit
=
int
(
self
.
request
.
GET
.
get
(
'limit'
,
self
.
limit
))
return
min
(
limit
,
self
.
limit
)
return
min
(
limit
,
self
.
limit
)
...
@@ -697,7 +699,9 @@ class PaginatorMixin(object):
...
@@ -697,7 +699,9 @@ class PaginatorMixin(object):
return
self
.
limit
return
self
.
limit
def
url_with_page_number
(
self
,
page_number
):
def
url_with_page_number
(
self
,
page_number
):
""" Constructs a url used for getting the next/previous urls """
"""
Constructs a url used for getting the next/previous urls
"""
url
=
URLObject
.
parse
(
self
.
request
.
get_full_path
())
url
=
URLObject
.
parse
(
self
.
request
.
get_full_path
())
url
=
url
.
add_query_param
(
'page'
,
page_number
)
url
=
url
.
add_query_param
(
'page'
,
page_number
)
...
@@ -708,7 +712,9 @@ class PaginatorMixin(object):
...
@@ -708,7 +712,9 @@ class PaginatorMixin(object):
return
url
return
url
def
next
(
self
,
page
):
def
next
(
self
,
page
):
""" Returns a url to the next page of results (if any) """
"""
Returns a url to the next page of results (if any)
"""
if
not
page
.
has_next
():
if
not
page
.
has_next
():
return
None
return
None
...
@@ -722,7 +728,9 @@ class PaginatorMixin(object):
...
@@ -722,7 +728,9 @@ class PaginatorMixin(object):
return
self
.
url_with_page_number
(
page
.
previous_page_number
())
return
self
.
url_with_page_number
(
page
.
previous_page_number
())
def
serialize_page_info
(
self
,
page
):
def
serialize_page_info
(
self
,
page
):
""" This is some useful information that is added to the response """
"""
This is some useful information that is added to the response
"""
return
{
return
{
'next'
:
self
.
next
(
page
),
'next'
:
self
.
next
(
page
),
'page'
:
page
.
number
,
'page'
:
page
.
number
,
...
...
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