﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27997	Can't get last() item of a paginator 'page'	Thomas Capricelli	nobody	"It's easy to reproduce with manage.py shell:


{{{
>>> from django.core.paginator import Paginator
>>> from xxx.models import *
>>> paginator = Paginator(YourFavoriteModel.objects.all(), 30)
>>> page = paginator.page(2)
>>> page.object_list.first() in page.object_list
True
>>> page.object_list.last() in page.object_list
False

# Even if unrolled:
>>> unrolled = [o for o in page.object_list]
>>> page.object_list.first() in unrolled
True
>>> page.object_list.last() in unrolled
False

}}}


Tested with python 2.7.13 and Django 1.8, 1.9 and 1.10.
I can reproduce it on several projects, with any Model that has an order defined in Meta. I can also reproduce for a Model that has none but adding an order_by(""field"") in the paginator=Paginator line.

What I do get with page.object_list.last() is indeed an item of the paginator queryset, but it doens't belong to the page, and is even far away. I have an example here where the item is in the middle of page 2 while i'm testing page 27 !

"	Bug	closed	Core (Other)	1.10	Normal	duplicate			Unreviewed	0	0	0	0	0	0
