title: Paginate a list of items in python flask
body: <p>I get a list of items in python by the following code:</p>
  
  <pre><code>from flask_paginate import Pagination
  @app.route('/retrieve_data')
  def retrieve():
      PER_PAGE=5
      connection = MongoClient()
      db=connection.rheoML
      fs = gridfs.GridFS(db)
      search = False
      q = request.args.get('q')
      if q:
          search = True
      try:
          page = int(request.args.get('page', 2))
      except ValueError:
          page = 1
      List=fs.list()
      pagination = Pagination(page=page,per_page=PER_PAGE, total=len(List), search=search, record_name='List')
      return   render_template("retrieveFile.html",List=List,fs=fs,form="submitIt",pagination=pagination,)
  </code></pre>
  
  <p>I am following the tutorial at <a href="https://pythonhosted.org/Flask-paginate/" rel="nofollow">https://pythonhosted.org/Flask-paginate/</a>
  Also I do the following in my retrieveFile.html to accomodate pagination :</p>
  
  <pre><code>&lt;form id="submitIt" name="submitIt" action="/GetFile" method="Post" onsubmit="return validate(this)"&gt;
  {{ pagination.info }}
  &lt;table&gt;
  &lt;tr&gt;
      &lt;th&gt;Select&lt;/th&gt;&lt;th&gt;Filename&lt;/th&gt;&lt;th&gt;Operator&lt;/th&gt;
  &lt;/tr&gt;
  {% for file in List %}
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input type="checkbox" name="FileName" value={{file.strip('u').strip("'")}}&gt;&lt;br&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;name="FileName1" id="file" value={{file.strip('u').strip("'")}}&gt;{{file.strip('u').strip("'")}}&lt;br&gt;
  &lt;/td&gt;
  &lt;td&gt;
  {{fs.get_last_version(file).Operator}}&lt;br&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  {% endfor %}
  &lt;/table&gt;
  {{ pagination.links }}
  &lt;input type="submit" value="Download"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I add this in my style tags</p>
  
  <pre><code>&lt;style&gt;
  .pagination-page-info {
      padding: .6em;
      padding-left: 0;
      width: 40em;
      margin: .5em;
      margin-left: 0;
      font-size: 12px;
  }
  .pagination-page-info b {
      color: black;
      background: #6aa6ed;
      padding-left: 2px;
      padding: .1em .25em;
      font-size: 150%;
  }
  &lt;/style&gt;
  </code></pre>
  
  <p>The problem is when the page is displayed, the page nos are fine but all the items are displayed in one page itself. Please help me, I am still a beginner in pagination and still trying to work things out</p>