1

我正在尝试为 python 获得一些 GAE 分页,但我什至无法让教程(https://docs.djangoproject.com/en/dev/topics/pagination/)正常工作。我在这里看到关于去哪里的相互矛盾的反应。这是我正在使用的代码:

class EditCompanyHandler(webapp.RequestHandler):

    # https://docs.djangoproject.com/en/dev/topics/pagination/

    def get(self):
        company_list = Company.all()    
        paginator = Paginator(company_list, 25) 




You are using the default Django version (0.96). The default Django version will change in an App Engine release in the near future. Please call use_library() to explicitly select a Django version. For more information see https://developers.google.com/appengine/docs/python/tools/libraries#Django

E 2012-05-25 06:31:36.341

<type 'exceptions.ImportError'>: cannot import name Paginator
Traceback (most recent call last):
  File "/base/data/home/apps/s~XX/1.359153909296057586/showcompanies.py", line 24, in <module>
    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

I 2012-05-25 06:31:36.343

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

我正在寻找一种直接的分页方式。

如果我将 djnago 版本更新到 1.1,我会得到以下信息:

<type 'exceptions.ImportError'>: cannot import name Paginator
Traceback (most recent call last):
  File "/base/data/home/apps/s~biomapit/1.359154059826228765/showcompanies.py", line 25, in <module>
    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
4

1 回答 1

0

我知道,如果你想导入分页器,你应该使用 django > 0.96 版本。然后在顶部的 showcompanies.py 中添加“from django.core.paginator import Paginator”这个模块。我认为你可以定义错误的代码部分(来自 django.core.paginator 导入 Paginator)模块我使用 django 1.2 版本并且分页器在我的项目中运行。

于 2012-12-05T09:56:38.833 回答