#9573: template filter length() should call .count() on querysets
---------------------------------------------------+------------------------
          Reporter:  wam                           |         Owner:  nobody
            Status:  reopened                      |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  1.1   
        Resolution:                                |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by miracle2k):

  * status:  closed => reopened
  * resolution:  wontfix =>
  * version:  1.0 => 1.1
  * component:  Template system => Database layer (models, ORM)

Comment:

 I just stumbled across this; For some reason I always assumed that {{
 queryset|length }} would do a count() when possible.

 Couldn't this be handled inside the ORM? I.e. __len__ doing a count()
 query for as of yet unexecuted querysets, and continuing to fetch the
 remainder of the result if the queryset was already touched?

 Clearly there is the downside of running an extra query in cases where the
 result is pulled later on anyway, but it may be worth the compromise.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9573#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=.


Reply via email to