我正在尝试为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
答案 0 :(得分:0)
我知道,你应该使用django&gt; 0.96版本,如果你想导入paginator。 并在showcome.py中添加“来自django.core.paginator import Paginator”的模块。 我认为你可以定义错误的代码部分(来自django.core.paginator import Paginator)模块 我使用了django 1.2版本,paginator正在我的项目中运行。