title: Python flask pagination passing form variable into query
body: <p>I am trying to pass a form variable into pagination.  If I hardcode the search, then my pagination works.  My non-hardcoded query works for page 1, but on trying to go into further pages I get the error:</p>
  
  <pre><code>TypeError: cannot concatenate 'str' and 'NoneType' objects
  </code></pre>
  
  <p>I only posted the code I thought was relevant.</p>
  
  <pre><code>@search.route('/search', methods=['GET', 'POST'])
  def search():
      form = searchForm()
      search_term = form.searchString.data
  
      print search_term
      search = False
      q = request.args.get('q')
      if q:
          search = True
  
      try:
          page = int(request.args.get('page', 1))
      except ValueError:
          page = 1
  
      PER_PAGE = 10
      inner_window = 4
      outer_window = 3
      offset = page * 1
  
  
      #doesnt work
      links = Item.query.filter(Item.title.like('%' + search_term + '%')).paginate(page, 10, True)
  
      #works
      links = Item.query.filter(Item.title.like('%hel%')).paginate(page, 10, True)
  
      #doesnt work at all
      #links = db.query.filter(func.mid(Item.description, 1, 3).all()).paginate(page, 10, True)
  
      total = Item.query.filter(Item.title.like('%' +search_term + '%')).count()
      pagination = get_pagination(page=page,
                                  links=links,
                                   per_page=PER_PAGE,
                                  offset=offset,
  
                                  search_term=search_term,
                                  inner_window=inner_window,
                                  outer_window = outer_window,
                                  search=search,
  
  
                                  total = total,        #total number of results
                                  format_total=True,   #format total. example 1,024
                                  format_number=True,  #turn on format flag
                                  record_name='links'
  
                              )
  
      return render_template('search/searchPage.html', form=form, links=links, pagination=pagination, page=page, per_page = PER_PAGE)
  </code></pre>
  
  <p>search_term prints the form input correctly on page 1, but page 2 onward prints "None"</p>