The {% for %} block of flask template would iterate over every item in your data (returned by get_hidden_interests) as is, so it's your task to prepare the correct data. Judging from the meaning of total_items and total_pages you might have mistakenly pass the whole database to it, instead of only required page of it. And get_hidden_interests accepting page and per_page feels like it should do the job, so there might be errors there.