原生分页
# 分页 def page(num, size = 10): # 接收当前页码数 num = int(num) # 总记录数 totalRecords = models.ReservoirData.objects.count() # 总页数 totalPages = int(math.ceil(totalRecords*1.0/size)) # math.ceil() 向上取整 1.2 --> 2.0 # 判断是否越界 if num < 1: num = 1 if num > totalPages: num = totalPages # 计算每页显示的记录 reservoirs = models.ReservoirData.objects.all()[((num-1)*size): (num*size)] return reservoirs, num