Detailed explanation of examples of paging effect using python flask

零下一度
Release: 2017-06-29 15:31:05
Original
2561 people have browsed it

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(&#39;/<int:page>&#39;)
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(&#39;home1.html&#39;,
              posts=posts,
              pagination=pagination,
              tuijian_post=tuijian_post,fenleis=fenlei,        
              links=link)
Copy after login

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 %}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!