﻿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
19938	django.core.paginator.Page.__getitem__ being called multiple times when used from a template.	joshua.fialkoff@…	andrewjesaitis	"Template code (using generic ListView):
{{{
{{ page_obj.number }}
{{ page_obj.number }}
{{ page_obj.number }}
}}}

When paired with a generic ListView, this will result in three calls to {{{ page_obj.__getitem__ }}} (presumably, because the template first tries to use 'number' as an index). Each call to {{{__getitem__}}} performs a {{{ list(self.object_list) }}}. In many cases, this will be quick - which, I suppose, is why it has escaped notice. In my specific case, {{{ object_list }}} is a generator, and each iteration performs a variety of functions (specifically, looking up other values that are of interest). So, this ultimately takes a while to run.

My workaround was simply to set {{{ page_obj.object_list = list(page_obj.object_list) }}} prior to it being used in the template. It seems the actual fix here would just be to perform this operation in {{{ __init__ }}}."	Cleanup/optimization	closed	Core (Other)	dev	Normal	fixed	paginator		Ready for checkin	1	0	0	0	1	0
