﻿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
26690	Add the option in the prefetch_related to have the prefetched results returned as a list or as a queryset	Arnaud B	nobody	"In his answer in ticket #26676, Simon Charette suggested me to open this ticket.

Currently, the result stored by prefetch_related is by default a queryset, unless Prefetch with to_attr is used, in which case it is a list. According to the [https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.Prefetch documentation about Prefetch], this trades the flexibility offered by the queryset for a considerable performance improvement.

I can see the rationale to have this behavior by default, but it seems to me it would be nicer to have an option to explicitly declare whether the results should be returned as a queryset or as a list:
1. In many cases, there is no need to chain further queries to the default prefetch_related. By explicitly asking for a list it would then become possible to benefit from the speed improvement.
2. Conversely, some developers may be happy to take the performance hit in order to further refine a Prefetch with to_attr.

This could be done via an optional boolean in prefetch_related, is_chainable or force_queryset or something like this (if left unset the current default behavior would apply). Does that sound like a good idea?"	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix	Prefetch prefetch_related queryset	Simon Charette	Unreviewed	0	0	0	0	0	0
