Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def webUI_periodic_task(request):
username = request.session.get('user','')
tasks = webtest_task.objects.all()
cases = Webcase.objects.all()
singel_tasks = webtest_task.objects.get_queryset().order_by('task_id')
paginator = Paginator(singel_tasks, 15) # 生成paginator对象,设置每页显示15条记录
page = request.GET.get('page', 1) # 获取当前页为第1页
currentPage = int(page) # 把当前页转换成整数
try:
singel_tasks = paginator.page(page) # 获取当前页码数的记录列表
except PageNotAnInteger:
singel_tasks = paginator.page(1) # 如果输入的页数不是整数则显示第1页内容
except EmptyPage:
singel_tasks = paginator.page(paginator.num_pages) # 如果输入的的页数不在系统的页数中,则显示最后一页
return render(request, "webcase_periodic_task.html", {"user": username, "singel_tasks": singel_tasks,"cases":cases,"tasks": tasks})