1
  1. Google App Engine 上的 Jinja2 有分页功能吗?

  2. 我正在考虑from django.core.paginator import Paginator从 django 使用。 https://docs.djangoproject.com/en/dev/topics/pagination/?from=olddocs

我想我需要在 app.yaml 中包含 django 库:

libraries:
- name: django
  version: "1.2"

但我想知道这是否会使我的应用程序运行速度变慢,因为我包含更多库。

4

1 回答 1

3

对于分页,建议使用 cursor 进行查询

q = ndb.query()
cursor = ndb.Cursor(urlsafe=self.request.get('cursor'))
items, next_curs, more = q.fetch_page(10, start_cursor=cursor) 
if more:
    next_c = next_curs.urlsafe()
else:
    next_c = None
self.generate('home.html', {'items': items, 'cursor': next_c })

并在模板中添加一个“更多”按钮

{% if cursor %}
    <a class="btn" href="?cursor={{cursor}}">more..</a>
{% endif %}

'旧' db.Model 是否有类似的东西

于 2012-08-22T07:31:16.313 回答