I propose the idea to narrow up the choices shown in list_filter, by those 
available among the "current" queryset's results.

Use case:
In a Book-Author-Publisher model, when looking for a particular book in the 
"list" view, you may first filter them by the author's name. From now on, 
I'd rather have the "publisher" filter show only publishers which have 
published a book with that author. 

<https://lh6.googleusercontent.com/-8PBR3iQfKDo/UiEOTCgArqI/AAAAAAAAAMc/4fueqNsYiww/s1600/django_filter.png>

Showing the "Bookless Publisher" in the filters is almost useless, and it'd 
be better omitted.

Another alternative for achieving the same goal would be prioritizing the 
choices in the filter by the number of "hits" in the current queryset's 
result. That way, those having zero corresponding record will be thrown 
down the list.

>From the implementation point of view, I have a hacked version of 
"AllValuesFieldListFilter" which does it right, although I think it may be 
done in a cleaner way, if someone knowing more about the code feels helpful.

Do you like the idea? Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to