Skip to content

Commit 482a5ca

Browse files
Cotixdavidism
authored andcommitted
Fix next_num and prev_num showing non existant page nums (pallets-eco#460)
1 parent 1ab23e2 commit 482a5ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

flask_sqlalchemy/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ def prev(self, error_out=False):
342342
@property
343343
def prev_num(self):
344344
"""Number of the previous page."""
345+
if not self.has_prev:
346+
return None
345347
return self.page - 1
346348

347349
@property
@@ -363,6 +365,8 @@ def has_next(self):
363365
@property
364366
def next_num(self):
365367
"""Number of the next page"""
368+
if not self.has_next:
369+
return None
366370
return self.page + 1
367371

368372
def iter_pages(self, left_edge=2, left_current=2,

0 commit comments

Comments
 (0)