#16647: Default filters: pacth to add  QuerySet support for random plus a new
shuffle filter
-------------------------------------+-------------------------------------
               Reporter:  h3         |          Owner:  nobody
                   Type:  New        |         Status:  new
  feature                            |      Component:  Template system
              Milestone:             |       Severity:  Normal
                Version:  1.3        |       Keywords:
             Resolution:             |      Has patch:  1
           Triage Stage:  Design     |    Needs tests:  1
  decision needed                    |  Easy pickings:  0
    Needs documentation:  1          |
Patch needs improvement:  1          |
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
Changes (by akaariai):

 * needs_docs:  0 => 1
 * stage:  Unreviewed => Design decision needed
 * needs_tests:  0 => 1
 * needs_better_patch:  0 => 1


Comment:

 I am not sure this is a good idea. The problem is that qs.order_by('?')[0]
 might be really expensive. If I am not mistaken, the DB must go through
 the whole result set and sort everything. Even if the DB returns just one
 row, that can be expensive. I am afraid that users of random do not
 realize this, as how could a fetch of just a single object cost much...

 Also, in the patch you use len(qs). That means the queryset gets evaluated
 (or at least count(*) is evaluated) there. try - except indexerror is
 better.

 Setting this to design decision needed.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16647#comment:2>
Django <https://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to