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)