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
815ef507
Commit
815ef507
authored
Aug 21, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If page size query param <= 0, just use default page size.
Closes #1028
parent
db25aaff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
+10
-1
rest_framework/generics.py
+10
-1
No files found.
rest_framework/generics.py
View file @
815ef507
...
...
@@ -14,6 +14,15 @@ from rest_framework.settings import api_settings
import
warnings
def
strict_positive_int
(
integer_string
):
"""
Cast a string to a strictly positive integer.
"""
ret
=
int
(
integer_string
)
if
ret
<=
0
:
raise
ValueError
()
return
ret
def
get_object_or_404
(
queryset
,
**
filter_kwargs
):
"""
Same as Django's standard shortcut, but make sure to raise 404
...
...
@@ -198,7 +207,7 @@ class GenericAPIView(views.APIView):
if
self
.
paginate_by_param
:
query_params
=
self
.
request
.
QUERY_PARAMS
try
:
return
int
(
query_params
[
self
.
paginate_by_param
])
return
strict_positive_
int
(
query_params
[
self
.
paginate_by_param
])
except
(
KeyError
,
ValueError
):
pass
...
...
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