Fixed #26226 -- Made related managers honor the queryset used for prefetching their results.

Thanks Loïc for the suggested improvements and Tim for the review.
This commit is contained in:
Simon Charette 2016-02-18 22:37:11 -05:00
parent 5d240b070d
commit c92123cc1d
6 changed files with 133 additions and 22 deletions

View file

@ -144,6 +144,9 @@ details on these changes.
* The ``__search`` query lookup and the
``DatabaseOperations.fulltext_search_sql()`` method will be removed.
* The shim for supporting custom related manager classes without a
``_apply_rel_filters()`` method will be removed.
.. _deprecation-removed-in-1.10:
1.10

View file

@ -762,6 +762,17 @@ features, is deprecated. Replace it with a custom lookup::
models.CharField.register_lookup(Search)
models.TextField.register_lookup(Search)
Custom manager classes available through ``prefetch_related`` must define a ``_apply_rel_filters()`` method
-----------------------------------------------------------------------------------------------------------
If you defined a custom manager class available through
:meth:`~django.db.models.query.QuerySet.prefetch_related` you must make sure
it defines a ``_apply_rel_filters()`` method.
This method must accept a :class:`~django.db.models.query.QuerySet` instance
as its single argument and return a filtered version of the queryset for the
model instance the manager is bound to.
Miscellaneous
-------------