扩展django.core.paginator Paginator以使用Google App Engine

时间:2010-04-20 23:22:16

标签: django google-app-engine paginator

如何扩展Paginator中的django.core.paginator课程以使用Google App Engine queries

1 个答案:

答案 0 :(得分:0)

必须进行以下更改:

from django.core.paginator import Paginator, Page

class GAEPaginator(Paginator):
    def page(self, number):
      "Returns a Page object for the given 1-based page number."
      number = self.validate_number(number)
      offset = (number - 1) * self.per_page
      if offset+self.per_page + self.orphans >= self.count:
        top = self.count
      return Page(self.object_list.fetch(self.per_page, offset), number, self)

很高兴Paginator知道GAE游标。

请随时修改此答案。