This article mainly introduces in detail python flask to achieve pagination effect. It has certain reference value. Interested friends can refer to it.
We will encounter such a problem in the process of learning, that is, in the process of learning, we will find that paging is needed. Here, I will introduce to you the paging mentioned in the book.
@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 paginated data I read from the database, so how do we paginate? Let’s see what the book says
Then we need to use a separate page to save our paging-related information.
So how do we use it
{% import "mac.html" as macros %}
Add the following after our loop
The effect is as shown
The above is the detailed content of Detailed explanation of examples of paging effect using python flask. For more information, please follow other related articles on the PHP Chinese website!