[Django]-Why is django slow to generate select boxes for foreign keys?

8👍

✅

Transferring huge select lists does take quite a bit of time. The markup can really start to add up. Try checking to see how large in KB/MB your html output is. I remember once seeing a select list (a few 1000 entries) bloat a page up to 5 or so megabytes at a previous job. This was on an ASP.NET project; it doesn’t really matter what framework you’re using when you have a problem like this.

I’m not sure if the django admin tool can do this, but it sounds like you really need a multi-level select list to drill down to results, rather than sending every option to the client at once.

1👍

1st thing to do is implement gzip on your site this will cut the size of responses at least in half.

Then, if it is still really slow maybe look into some type of ajax auto-suggest type widget to handle selecting the right value. Looks like there is aleady some documented solutions for this: http://www.google.com/#hl=en&q=django+autocomplete+widget&btnG=Google+Search&aq=1&oq=django+autocomplete+widget&fp=jFFhzb_S4-4

Leave a comment