Discuss / Python / 定义/路由的时候,Page函数是否少穿了一个pageindex参数啊 廖老师

定义/路由的时候,Page函数是否少穿了一个pageindex参数啊 廖老师

Topic source

FreeMind_X

#1 Created at ... [Delete] [Delete and Lock User]

发现点击下一页没有作用发现的

@get('/')
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)')
    page = Page(num)  #<---------------这里???
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit))
    return {
        '__template__': 'blogs.html',
        'page': page,
        'blogs': blogs
    }

笑然一生

#2 Created at ... [Delete] [Delete and Lock User]

确实是这样的,我也发现啦

一雷叔一

#3 Created at ... [Delete] [Delete and Lock User]

首页默认的就是取的最新的10条记录而已, blogs.html 模板里边也没有设置翻页,和传递 page_index 的JS代码

page_index = get_page_index(page)

这一段代码本来就是多余的,没有用到 page_index 变量

一雷叔一

#4 Created at ... [Delete] [Delete and Lock User]

是我没有更新代码, 呵呵 收回

最新的blogs.html 加了这句调用代码: {{ pagination('/?page=', page) }}


  • 1

Reply