Quick Filter in the Admin Sidebar

198 views
Skip to first unread message

Maxim Milovanov

unread,
Nov 18, 2020, 3:13:02 PM11/18/20
to Django developers (Contributions to Django itself)
Hey guys,

I've posted a ticket with a proposal to add a quick filtering feature to the sidebar.
To see it in action just replace the content of nav_sidebar.html by this gist

Does it worth adding to the admin features? Hope for any feedback.

Thanks,
Maxim

Yasiel Cabrera

unread,
Nov 19, 2020, 8:50:37 AM11/19/20
to Django developers (Contributions to Django itself)
I found this feature very helpful. I'm maintaining two sites with more than 20 models registered in the admin and some time is annoying when I try to find the one I'm looking for

Maxim Milovanov

unread,
Nov 19, 2020, 9:16:11 AM11/19/20
to Django developers (Contributions to Django itself)
Yeah, that's why I came up with that idea. There are two projects, 44 models on one, 57 models on another. It's very hard to navigate

четверг, 19 ноября 2020 г. в 16:50:37 UTC+3, yasie...@gmail.com:

Tom Carrick

unread,
Nov 19, 2020, 9:38:25 AM11/19/20
to django-d...@googlegroups.com
I haven't looked at the gist, but I think in principle it's a good idea. ctrl+f isn't ideal.

I think we need to be careful that the UX is good, if we go with this.

Tom

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8376528d-a2df-43b0-829e-43a49bd44dddn%40googlegroups.com.

Collin Anderson

unread,
Dec 2, 2020, 12:46:30 PM12/2/20
to Django developers (Contributions to Django itself)
I think this would be really helpful. Looking at the code in the gist, that looks about right. It's not too complicated and the basic toLowerCase()/indexOf() method of search should hopefully be enough (it's what I would do if I were implementing this!). I'd suggest adding some sort of clear or x button for canceling/removing the filter, but otherwise I think this should be ok UX wise. We can always improve it later.

Maxim Milovanov

unread,
Dec 4, 2020, 3:42:56 AM12/4/20
to Django developers (Contributions to Django itself)
Hey guys,

I'm not sure that the nav_sidebar.html is the best place for the JS snippet. Probably, it should be placed in the main JS. When DOM is ready it can be initialized there.

About UX. Agree the the "Clear" feature would be useful. It can be an "x" icon, or a shortkey (ESC?), or both.

I'll provide a working sample later.

Thanks,
Maxim 

среда, 2 декабря 2020 г. в 20:46:30 UTC+3, Collin Anderson:

Adam Johnson

unread,
Dec 4, 2020, 4:00:35 AM12/4/20
to django-d...@googlegroups.com
I'm not sure that the nav_sidebar.html is the best place for the JS snippet. Probably, it should be placed in the main JS. When DOM is ready it can be initialized there.

Indeed, we can't use inline JS in the admin since that doesn't work with a strict CSP.



--
Adam

Maxim Milovanov

unread,
Dec 4, 2020, 7:01:41 AM12/4/20
to Django developers (Contributions to Django itself)
Hey guys,

I've updated my prototype. What's changed:
-- moved the JS and CSS to nav_sidebar.js and nav_sidebar.css respectively
-- slight changes in styling
-- added ESC key support

My changes are:
nav_sidebar.html: line 4
nav_sidebar.css: line 121 and below
nav_sidebar.js: line 40 and below

I've attached a git patch file as well.

Thanks,
Maxim

пятница, 4 декабря 2020 г. в 12:00:35 UTC+3, Adam Johnson:
quick_filter_patch.diff

Tom Carrick

unread,
Jan 9, 2021, 4:21:19 AM1/9/21
to django-d...@googlegroups.com
Hi Maxim,

I think the best thing you can do is add a ticket on trac - https://code.djangoproject.com/ and make a PR on GitHub if it's accepted. I think it's hard - at least for me - to test something from a gist. Then you will get some reviews and more feedback.

Cheers,
Tom

Carlton Gibson

unread,
Jan 10, 2021, 1:52:56 AM1/10/21
to django-d...@googlegroups.com
I originally sent the ticket here to see if folks were keen. 
Given discussion here, I’ve adjusted to Accepted. 
Next step would be a PR.

Thanks all. 


Maxim Milovanov

unread,
Jan 10, 2021, 8:10:07 AM1/10/21
to Django developers (Contributions to Django itself)
Hey guys,

I've just created a PR, please review https://github.com/django/django/pull/13873

воскресенье, 10 января 2021 г. в 09:52:56 UTC+3, carlton...@gmail.com:
Reply all
Reply to author
Forward
0 new messages