Paginating records
The paginate()
method makes it easy to grab a page or records. paginate()
takes two parameters, page_number
, and items_per_page
.
Attention
Page numbers are 1-based, so the first page of results will be page 1.
>>> for tweet in Tweet.select().order_by(Tweet.id).paginate(2, 10):
... print(tweet.message)
...
tweet 10
tweet 11
tweet 12
tweet 13
tweet 14
tweet 15
tweet 16
tweet 17
tweet 18
tweet 19
If you would like more granular control, you can always use limit()
and offset()
.