Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Prevent division by zero error in paginated resources
Browse files Browse the repository at this point in the history
See chop-dbhi/harvest#36

Signed-off-by: Byron Ruth <b@devel.io>
  • Loading branch information
bruth committed Oct 9, 2014
1 parent 6d07872 commit 0b12dc4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion serrano/resources/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get_paginator(self, queryset, limit):
# Perform count an update paginator to prevent redundant call
if not limit:
count = len(queryset)
paginator.per_page = count
# Prevent division by zero error in case count is zero
paginator.per_page = max(count, 1)
paginator._count = count

return paginator
Expand Down

0 comments on commit 0b12dc4

Please sign in to comment.