Using Flask & MongoDB to add pagination

Apr 15, 2015

With a growing number of public GitHub events, [Ask GitHub] ( 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.




  • github
  • analytics
  • mongodb
  • python
  • flask
Harish Chakravarthy Harish Chakravarthy is an intrapreneur leveraging technology to make a positive difference. Interests include API integration, user experience, data visualization and analytics. Detailed bio.

Connect with Harish on Social Media Github Twitter LinkedIn