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
a3afcfb6
Commit
a3afcfb6
authored
Jul 13, 2015
by
homm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
duplicate `get_page_size` and related properties from PageNumberPagination
parent
59905e93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletions
+27
-1
rest_framework/pagination.py
+27
-1
No files found.
rest_framework/pagination.py
View file @
a3afcfb6
...
@@ -491,13 +491,26 @@ class CursorPagination(BasePagination):
...
@@ -491,13 +491,26 @@ class CursorPagination(BasePagination):
http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api/
http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api/
"""
"""
cursor_query_param
=
'cursor'
cursor_query_param
=
'cursor'
# The default page size.
# Defaults to `None`, meaning pagination is disabled.
page_size
=
api_settings
.
PAGE_SIZE
page_size
=
api_settings
.
PAGE_SIZE
# Client can control the page size using this query parameter.
# Default is 'None'. Set to eg 'page_size' to enable usage.
page_size_query_param
=
None
# Set to an integer to limit the maximum page size the client may request.
# Only relevant if 'page_size_query_param' has also been set.
max_page_size
=
None
invalid_cursor_message
=
_
(
'Invalid cursor'
)
invalid_cursor_message
=
_
(
'Invalid cursor'
)
ordering
=
'-created'
ordering
=
'-created'
template
=
'rest_framework/pagination/previous_and_next.html'
template
=
'rest_framework/pagination/previous_and_next.html'
def
paginate_queryset
(
self
,
queryset
,
request
,
view
=
None
):
def
paginate_queryset
(
self
,
queryset
,
request
,
view
=
None
):
if
self
.
page_size
is
None
:
self
.
page_size
=
self
.
get_page_size
(
request
)
if
not
self
.
page_size
:
return
None
return
None
self
.
base_url
=
request
.
build_absolute_uri
()
self
.
base_url
=
request
.
build_absolute_uri
()
...
@@ -577,6 +590,19 @@ class CursorPagination(BasePagination):
...
@@ -577,6 +590,19 @@ class CursorPagination(BasePagination):
return
self
.
page
return
self
.
page
def
get_page_size
(
self
,
request
):
if
self
.
page_size_query_param
:
try
:
return
_positive_int
(
request
.
query_params
[
self
.
page_size_query_param
],
strict
=
True
,
cutoff
=
self
.
max_page_size
)
except
(
KeyError
,
ValueError
):
pass
return
self
.
page_size
def
get_next_link
(
self
):
def
get_next_link
(
self
):
if
not
self
.
has_next
:
if
not
self
.
has_next
:
return
None
return
None
...
...
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