【发布时间】:2019-08-08 06:25:51
【问题描述】:
在我的应用程序中,我只有当前页面和总页数的数据。我可以从任何页面请求数据,但只能请求一个。这种情况下如何实现Django分页?
例如,我有一个函数,它接受页数并返回此页数据和总页数:
def get_data(start=0):
if start == 0:
return {'data': ['zero data', 'zero data', 'for zero page'], 'total_pages': 4}
if start == 1:
return {'data': ['second data', 'first page data', 'for first page'], 'total_pages': 4}
if start == 2:
return {'data': ['third data', 'third data', 'for second page'], 'total_pages': 4}
if start == 3:
return {'data': ['fourth data', 'fourth data', 'for third page'], 'total_pages': 4}
【问题讨论】:
标签: django django-templates django-views