从数据库取出数据,根据事先定义的每页显示的数量,进行分页计算,得到页数,构造html,返回给前端解析显示。
大致分为两种:
def page_student_list(request,page):
# page = int(page)
# start_num = (page-1)*10
# end_num = page*10
# db_student = Student.objects.all()
#
# student_count = db_student.count() #返回查询的条数
#
# #判断页码的范围
# pageEnd = student_count/10
# if pageEnd != int(pageEnd):
# pageEnd += 1
#
# if page < 3:
# page_start = 1
# page_end = 5
# # page_range = range(1, 6)
# else:
# page_start = page-2
# page_end = page+3
#
# if page_end >= pageEnd: #分页尾部
# page_end = pageEnd
#
#
# page_range = range(page_start, int(page_end)+1)
# #page_range = range(1,int(page_end)+1 ) #获取分页列表
#
#
# students = db_student[start_num:end_num]
# if not studen