Python flask For an example of paging effect

Source: Internet
Author: User
This article is mainly for everyone to introduce the Python flask to achieve paging effect, with a certain reference value, interested in small partners can refer to

In the course of our study will encounter such a problem, that is, in the course of our study will find the need for paging processing, here, to introduce you to the page of the book said.


@app. Route ('/', methods=[' GET ') @app. Route ('/<int:page> ') def Home (page=1):  pagination=post.query.order _by (Post.publish_date.desc ()). Paginate (page, per_page=10,error_out=false)  posts = pagination.items  link, Tuijian_post,fenlei=get_tui_link ()  return render_template (' home1.html ',              posts=posts,              pagination= Pagination,              Tuijian_post=tuijian_post,fenleis=fenlei,                      links=link)

This is the paging data I read from the database, so how do we split the page, and we'll see what the book says.

Then we need to take a separate page to save our paging related,.

So how do we use it?


{% import "mac.html" as Macros%}

After our loop, add the following

Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.