Python flask pagination passing form variable into query -
i trying pass form variable pagination. if hardcode search, pagination works. non-hardcoded query works page 1, on trying go further pages error:
typeerror: cannot concatenate 'str' , 'nonetype' objects
i posted code thought relevant.
@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 @ #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)
search_term prints form input correctly on page 1, page 2 onward prints "none"