繁体   English   中英

使用Django模板分页并在行中显示记录

[英]Pagination and displaying records in rows with Django templates

我正在尝试对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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM