Python Road--web--2--django-9-pagination

Source: Internet
Author: User

Six, pagination

I. Django built-in paging

views.pyHtmlextended built-in paging: views.pyextended built-in paging: Html

Second, custom paging

Paging functionality is necessary for each site, and for paging, it is the user's input that calculates the starting position in the database table.

1. Set the number of data bars per page

2. User Input page number (first page, second page ...) )

3, according to the set of each page shows the number of bars and the current page number, calculate the need to take the data table starting position

4, in the data table according to the starting position value, the page output data

The demand is coming again, and the page needs to be displayed on the page. such as: [Previous][1][2][3][4][5][next page]

1. Set the number of data bars per page

2. User Input page number (first page, second page ...) )

3. Set the number of pages displayed

4. Get the total number of current data

5, according to the set display number of pages and the total number of data calculated, total pages

6, according to the set of each page shows the number of bars and the current page number, calculate the need to take the data table starting position

7, in the data table according to the starting position value, the page output data

8, output pagination HTML, such as: [Prev][1][2][3][4][5][Next]

Pagination Instance

To summarize, there are three things to do when paging:

    • To create a class that processes paging data
    • Get data based on paging data
    • Output pagination HTML, that is: [prev][1][2][3][4][5][Next]

Python Road--web--2--django-9-pagination

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.