From 98e8da3709e400d549e87c7ff1450a2685c0adcf Mon Sep 17 00:00:00 2001 From: Stanislas Guerra Date: Wed, 21 May 2014 12:32:19 +0200 Subject: Fixed #16311 -- Added a RelatedOnlyFieldListFilter class in admin.filters. --- docs/ref/contrib/admin/index.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 958551d660..8d69ac6e82 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -880,6 +880,20 @@ subclass:: ('is_staff', admin.BooleanFieldListFilter), ) + .. versionadded:: 1.8 + + You can now limit the choices of a related model to the objects + involved in that relation using ``RelatedOnlyFieldListFilter``:: + + class BookAdmin(admin.ModelAdmin): + list_filter = ( + ('author', admin.RelatedOnlyFieldListFilter), + ) + + Assuming ``author`` is a ``ForeignKey`` to a ``User`` model, this will + limit the ``list_filter`` choices to the users who have written a book + instead of listing all users. + .. note:: The ``FieldListFilter`` API is considered internal and might be -- cgit v1.3