NumericListfilter or similar

87 views
Skip to first unread message

Omer Korner

unread,
Apr 19, 2016, 10:49:36 AM4/19/16
to Django developers (Contributions to Django itself)
This is a proposal for a new ListFilter subclass.

Currently, if you add a numeric field to list_filter, Django admin outputs all possible values of that field using AllValuesFieldListFilter. This can get ugly very quickly.
For example, in my case, I have an application that manages transactions (orders) from an ecommerce site, and saves the transaction value. I can't easily filter the values (hundreds of thousands of them).

I have two suggestions for a replacement, instead of outputting all available values for a numeric field:

  1. Output something similar to what DateFieldListFilter does, eg. "10 or less/more, 15 or less" and so on, depending on real values. 



  2. A numeric input. These an be two inputs for a range, or a single input for a specific value. Looking at the ListFilter code, this would be a much more complex change.

Happy to hear your thoughts.

John Griebel

unread,
Apr 19, 2016, 1:19:02 PM4/19/16
to django-d...@googlegroups.com
I agree that we need a replacement; the current behaviour isn't all that useful, IMHO. My vote would for choice #2, after all it seems more natural (to me, at least), to think of numbers as a range, especially while searching. Option 1 seems less intuitive for a situation like this.

+1 from me, especially if we were to go with option 2.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9ef08349-f6a6-48ed-bc30-5b62072fb749%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Graham

unread,
Apr 26, 2016, 8:35:17 PM4/26/16
to Django developers (Contributions to Django itself)
Does it need to be in Django itself? I'd think probably not, at least to start, but if there's something prohibiting that, then let us know.

Omer Korner

unread,
Apr 30, 2016, 3:04:47 PM4/30/16
to Django developers (Contributions to Django itself)

Cristiano Coelho

unread,
Apr 30, 2016, 3:39:44 PM4/30/16
to Django developers (Contributions to Django itself)
Implementing a custom filter with an arbitrary text input is quite easy. All you need is a template and subclass of ListFilter. However I agree that it could be great that it comes already as an option by django since ListFilter and FieldFilter are usually not enough.
Reply all
Reply to author
Forward
0 new messages