最近在学习Tornado,在写分页的时候遇到了瓶颈。
是参照这个问答进行写的:
http://stackoverflow.com/questions/15981257/can-tornado-handle-pagination
路径就是:(r"/",MainHandler)
逻辑是:
class MainHandler(BaseHandler):
def get(self,template_variables = {}):
news_timeline = self.news_model.get_all_news() #获取所有news
current_page = int(self.get_argument('page',0)) # 获取当前URL里的page参数
template_variables["news_timeline"] = news_timeline
template_variables["current_page"] = current_page
self.render("index.html",**template_variables)
HTMl是:
<body>
{% for news in news_timeline %}
<a href = "{{ news["news_link"] }}">{{ news["news_name"] }}</a>
{% end %}
{% module Paginator(current_page,5, len(news_timeline)) %}
</body>
但是底部的分页链接能够显示出来,可是所有结果都显示在了一个页面,并没有分开显示。现在找不到问题在哪里,是我少些了什么代码吗?
各位大神,求教!!!
是参照这个问答进行写的:
http://stackoverflow.com/questions/15981257/can-tornado-handle-pagination
路径就是:(r"/",MainHandler)
逻辑是:
class MainHandler(BaseHandler):
def get(self,template_variables = {}):
news_timeline = self.news_model.get_all_news() #获取所有news
current_page = int(self.get_argument('page',0)) # 获取当前URL里的page参数
template_variables["news_timeline"] = news_timeline
template_variables["current_page"] = current_page
self.render("index.html",**template_variables)
HTMl是:
<body>
{% for news in news_timeline %}
<a href = "{{ news["news_link"] }}">{{ news["news_name"] }}</a>
{% end %}
{% module Paginator(current_page,5, len(news_timeline)) %}
</body>
但是底部的分页链接能够显示出来,可是所有结果都显示在了一个页面,并没有分开显示。现在找不到问题在哪里,是我少些了什么代码吗?
各位大神,求教!!!