1
我試圖讓一些分頁GAE python,但我甚至無法獲得教程(https://docs.djangoproject.com/en/dev/topics/pagination /)工作。我在這裏看到了相互衝突的答案。這裏是我使用的代碼:分頁和顯示與Django模板行記錄
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
'def get(self)...'是你使用的所有代碼?沒有進口? –
@reos,不,這只是一個剪輯 – Androidian
嘗試擴展'EditCompanyHandler'類Paginator太多,就像這個'類EditCompanyHandler(webapp.RequestHandler,Paginator):' –