One use-case remains inelegant: using a custom `QuerySet` with default
`QuerySet` customization/filtering:
{{{
BaseCustomManager = Manager.from_queryset(CustomQueryset)
class CustomManager (BaseCustomManager ):
def get_queryset(self):
queryset = super(Manager, self).get_queryset()
return queryset.filter(...)
}}}
This ticket proposes adding a hook on `QuerySet` to enable this without
requiring a custom `Manager`.
--
Ticket URL: <https://code.djangoproject.com/ticket/23533>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by loic):
It's worth noting that `QuerySet.__init__()` can't be used for providing
such initialization/customization:
- QuerySet are often cloned, and the customization should only ever apply
once.
- QuerySet methods return a cloned QuerySet instance and `__init__` can't
return a different instance.
So far the best option I can think of is a hook called externally by the
manager.
POC with a `QuerySet.get_initial_queryset()` method
https://github.com/loic/django/compare/ticket23533
--
Ticket URL: <https://code.djangoproject.com/ticket/23533#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/23533#comment:2>