﻿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
9573	template filter length() should call .count() on querysets	wam	nobody	"Currently, `django.template.defaultfilters.length()` just calls `len()` on the passed in value. If the passed in value is queryset, `len(queryset)` of course ends up calling `django.db.query.QuerySet().__len__()`. This method ends ends up mapping the queryset into a list and calling `len()` on the resulting list (it will also of course use cached versions of the queryset list, but in all cases, the queryset gets expanded into an in-memory list). 

I'd like to suggest that `django.template.defaultfilters.length()` instead do something like:

{{{
def length(value):
  """"""Returns the length of the value - useful for lists.""""""
  try:
     value.count()
  except:
     return len(value)
}}}

"		closed	Database layer (models, ORM)	1.1		wontfix			Unreviewed	0	0	0	0	0	0
