Using Flask & MongoDB to add pagination
With a growing number of public GitHub events, [Ask GitHub] (http://askgithub.com) search results had to be displayed in multiple pages. Using flask-paginate, a pagination extension for flask, implemenation pagination is a snap!
Below are the steps and my notes. Feedback welcome!
Step 1: Install flask-paginate
Step 2: Initialize
Step 3: Render templates with pagination
Step 4: Call pagination with options
Step 5: Include pagination tags inside templates
Step 6: CSS (optional)
Step 7: MongoDB queries to handle pagination
I had to rewrite
aggregate function to create an array to latter
unwind for finding numbers of rows returned for a specific query.
skip lets you skip over earlier search results and
limit limits returned rows.