#20625: Custom Chainable QuerySets
-------------------------------------+-------------------------------------
     Reporter:  danols               |                    Owner:  danols
         Type:  New feature          |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  QuerySet,            |      Needs documentation:  0
  models.Manager, chainable          |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by lukeplant):

 * stage:  Unreviewed => Accepted


Comment:

 I'm accepting the ticket in principle - we need a solution to this
 problem, evidenced by the number of solutions/complaints out there:

 https://github.com/zacharyvoase/django-qmethod
 http://stackoverflow.com/questions/4576622/in-django-can-you-add-a-method-
 to-querysets
 http://djangosnippets.org/snippets/562/
 http://djangosnippets.org/snippets/734/
 http://djangosnippets.org/snippets/2114/
 http://djangosnippets.org/snippets/2117/


 And I don't think having multiple solutions to this problem helps people -
 it just adds more-than-one-way-to-do-it.

 However, I'm not at the moment accepting the approach given in the ticket
 (neither am I rejecting it). We need to consider the pros/cons of the
 different methods in the existing solutions above.

 For the solution in the PR above, I'd say the major disadvantage is that
 you have methods on the Manager which are not being used as Manager
 methods, but callables that could be attached to either Managers or
 !QuerySets. This means surprises w.r.t to `self` (as documented in the
 example), and it would be easy to think it is working (because it works
 without chaining), or to have nasty surprises if you call methods that
 exist on !QuerySet but have been overridden on the Manager subclass.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20625#comment:4>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d41599a916c3b0b0dff2e6aa8ff4b7ee%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to