Admin widget for filter_vertical and filter_horizontal slow

469 views
Skip to first unread message

maco

unread,
Apr 16, 2009, 4:40:35 AM4/16/09
to Django users
My model has two Foreign Keys. Each FK has 4000 entries or more. In
admin.py I use filter_horizontal for those FK.

I noticed that JS widget is slow both on first render of admin page
(add item) and on every selection of an FK item inside the widget. I
takes 5 seconds AFTER admin page already loads for JS to render
widget. In this time browser is unresponsive. Selection of an item
takes even longer.

I've tested this on various browsers and systems.

I'm am fairly confident that the number of FK items is a major factor
in slowing down the render of the widget because I tried deleting FK
items and browser was starting to show improvements in speed. When the
number of FK items dropped under 1000 admin site become much faster
(and actually usable).

I've also completely removed filter_horizontal just to be sure nothing
is wrong with admin on a general and all seemed good and super fast.

So, I recon, some revision of JS for filter in admin is needed or sth.

Thanks for any thoughts on that.

Christopher Dodd

unread,
Apr 16, 2009, 11:01:13 AM4/16/09
to Django users
Yeah, this is a known issue. http://code.djangoproject.com/ticket/3202
I ran into it myself and have been trying all kinds of things to work
around it.
Once you get enough rows in a table the default controls are no longer
feasible.

Have you looked into the raw_id_fields option? It wasn't an option for
me but it might help you.
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options

maco

unread,
Apr 17, 2009, 4:01:55 AM4/17/09
to Django users
Thanks, that's a nice workaround. I'll give it a thought. Having a
input filed widget instead of select plus some JS for suggested
search. I use jquery.liveSearch.js allready on a title in my model.




On 16 apr., 17:01, Christopher Dodd <dodd.ch...@gmail.com> wrote:
> Yeah, this is a known issue.http://code.djangoproject.com/ticket/3202
> I ran into it myself and have been trying all kinds of things to work
> around it.
> Once you get enough rows in a table the default controls are no longer
> feasible.
>
> Have you looked into the raw_id_fields option? It wasn't an option for
> me but it might help you.http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-op...
Reply all
Reply to author
Forward
0 new messages