0

Following this example,

Pagination example

I tried to use it with one of my models.

def index(request):
    firstTen = Person.objects.all()
    pagination = Paginator(firstTen, 2)

    page = request.GET.get('page')

    try:
        people = pagination.page('page')
    except PageNotAnInteger:
        people = pagination.page(1)


    return render_to_response('index.html', {'people': people},
        context_instance=RequestContext(request))

For some reason i am getting 'Page' object is not iterable when using it in my view like so

{% for result in people %}
{% endfor %}
4

1 回答 1

1

您的脚本中有一个错字:该行people = pagination.page('page')应该是people = pagination.page(page). 错误消息的线索是它期待一个Page对象,而无论它得到什么似乎都不像一个对象。

于 2013-01-09T19:22:33.387 回答