Python flask-paginate returning too many results on page -
im using module flask-paginate found here: http://pythonhosted.org/flask-paginate/
i able return results, , pagination begins correct number of pages, showing 69 results per page. documentation shows per_page= , affects starting page number correct. im using sql-alchemy db.
@search.route('/search') def search(): page, per_page, offset, inner_window = get_page_items() links = item.query.all() total = item.query.count() pagination = get_pagination(page=page, per_page=per_page, total = total, format_total=true, format_number=true, record_name='links', ) return render_template('search/searchpage.html', offset=offset, total=total, links=links, pagination=pagination, per_page=per_page, page=page) def get_css_framework(): return 'bootstrap3' def get_link_size(): return 'sm' #option lg def show_single_page_or_not(): return false def get_page_items(): page = int(request.args.get('page', 1)) per_page = 10 inner_window=10 offset = (page) * 10 return page, per_page, offset, inner_window def get_pagination(**kwargs): kwargs.setdefault('record_name', 'repositories') return pagination(css_framework=get_css_framework(), link_size=get_link_size(), show_single_page=show_single_page_or_not(), **kwargs )
if print out page
see returns 1
since trying access request
outside of scope, search route function, , .get()
returning 1
.
try this...
@search.route('/search') def search(): ... page = int(request.args.get('page', 1)) per_page = 10 inner_window = 10 offset = page * 10 ...
if want continue use separate function need pass request
object in order access values.
hope helps!
Comments
Post a Comment