[Oldboy-django] [2 in-depth Django] student management (Form)--View (pagination)

Source: Internet
Author: User

1 needs: View all student's information, (paging function)

2 Front end: Bootstrap beautification front end

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Title</title>    <Linkrel= "stylesheet"href= "/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">    <Linkrel= "stylesheet"href= "/static/plugins/font-awesome-4.7.0/css/font-awesome.css"></Head><Body><h4>Student Management</h4>        <P>            <ahref= "/app01/add_student"class= "Btn btn-primary">Add to</a>        </P>        <Tableclass= "Table table-striped table-bordered table-hover table-condensed">            <thead>                <TR>                    <th>Id</th>                    <th>Name</th>                    <th>Age</th>                    <th>Mailbox</th>                    <th>Class</th>                    <th>Operation</th>                </TR>            </thead>            <tbody>{% for item in student_list%}<TR>                        <TD>{{Item.id}}</TD>                        <TD>{{Item.name}}</TD>                        <TD>{{Item.age}}</TD>                        <TD>{{Item.email}}</TD>                        <TD>{{item.cls_id}}</TD>                        <TD>                            <ahref= "/app01/edit_student/nid={{Item.id}}"class= "Glyphicon glyphicon-pencil">Edit</a>| <ahref= "/app01/del_student/nid={{Item.id}}"class= "Glyphicon Glyphicon-trash">Delete</a>                        </TD>{#点击删除是一个get请求, to tell the server ID, you can get it through a URL get request, or a URL match to a pass to the view #}</TR>{% endfor%}</tbody>        </Table>        <navAria-label= "Page navigation">            <ulclass= "pagination">{{Page_info.pager|safe}}</ul>        </nav></Body></HTML>
View Code

3 views

defstudents (Request): fromUtils.pagation_defineImportPageInfo Current_page_number= Request. Get.get ('page') All_count=models. Classes.objects.all (). Count () Page_info= PageInfo (Current_page_number, All_count,"/app01/students") Stu_list=models. Student.objects.all () [Page_info.start ():p age_info.end ()]returnRender (Request,'app01_student_list.html', {'student_list': Stu_list})
View Code

 

[oldboy-django][2 in-depth Django] student management (Form)--view (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.