per_page = 15
p = Paginator(logs, per_page)
if self.page > p.num_pages:
self.page = p.num_pages
self.next_page = False
self.end_page = True
self.next_next_page = False
elif self.page == p.num_pages:
self.next_page = False
self.next_next_page = False
self.end_page = True
elif self.page == p.num_pages-1:
self.next_page = True
self.next_next_page = False
self.end_page = True
elif self.page == p.num_pages-2:
self.next_page = True
self.next_next_page = True
self.end_page = True
else:
self.next_page = True
self.next_next_page = True
self.end_page = False
if per_page < p.count:
self.paginator_active = True
else:
self.paginator_active = False
page = p.page(self.page)
self.pages = p.num_pages
return page.object_list
django view视图模块里使用到的分页代码,如何用更方便的python控制流改写?
先不说你其他代码,只针对你贴出来的代码
这种东西哪用if?巭孬啊少年