Tag: django pagination

如何在AJAX调用上重新呈现django模板代码

我有一个视图,它将分页对象(在查询集上)发送到模板,我在模板中进一步呈现为一个表。 我要做的是点击模板上的分页栏上的页码,它应该进行ajax调用以获取该页码的分页输出并动态更新表的内容。 视图: def accounts(request): #Including only necessary part accounts_list = Accounts.objects.all() paginator = Paginator(accounts_list, 25) page = request.GET.get(‘page’) try: accounts = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. accounts = paginator.page(1) except EmptyPage: # If page is out of range, deliver last page of results. accounts = paginator.page(paginator.num_pages) […]