Skip to content

Commit

Permalink
fixup! Django: fixes pagination parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
cawal committed Dec 22, 2021
1 parent 486dd04 commit 119837d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions restless/dj.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def serialize_list(self, data):
if getattr(self, 'paginate', False):
page_size = getattr(self, 'page_size', getattr(settings, 'RESTLESS_PAGE_SIZE', 10))
paginator = Paginator(data, page_size)

page_number = int(self.request.GET.get('p', 1))
try:
page_number = int(self.request.GET.get('p', 1))
except ValueError:
raise BadRequest('Invalid page number')

if page_number not in paginator.page_range:
raise BadRequest('Invalid page number')
Expand Down

0 comments on commit 119837d

Please sign in to comment.