My site has a navbar with an advanced search widget (beside the search field), which renders on every page. For each request, a context_processor creates the form so it can be available on that page in the navbar. This form has about a dozen selects with a total of several hundred options. Most of those options are for the currency and country selects, along with about 80 other options. There is an even larger list for "stores" but it is loaded via AJAX so it should not be a factor here.
Performance was fine on Django 1.8, but after upgrading to 1.11 I noticed with NewRelic that over 500 ms are now being used on my most frequent request between the following:

This seems to be related to 1.11's change to Template-based Widget Rendering (docs), however the only pages I could find talking about related problems were about Django Toolbar which I do not run in production.
I am and already using the Cached Template Loader (which is now default), however I don't know if this helps here. I cannot easily cache this form because as you can see in the code, I set a number of defaults based on the request.
Why is my form suffering so badly from this change? Eliminating two of the bigger selects helps, but surely several hundred options should not take this long to render so it seems to me there is an underlying problem that the quantity is merely exacerbating.
Here are links to to code for the full form and html. (I will include snippets in the question later when we identify the problem, for future readers).
--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/uhe7ExBJoxg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b4a2a1d1-63e2-4a14-a5fa-2e75a018dadf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am still hoping however for someone to explain to me why the default renderer cannot handle my use case, such as that a few hundred inputs is too many, or that I am doing something else improperly. Surely this kind of a change would not be made to the framework that would cause such an unacceptable performance (500+ms added). Kind of disappointing to spend a whole week upgrading only to end up wanting to downgrade again.
--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/uhe7ExBJoxg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL13Cg9amLPan9-pj%2BHpHc7vns6_5EJcvNHvF0VPakf651%3DT1g%40mail.gmail.com.
So my takeaway from what you are saying is that no one is running a production site with a Django select field to render a country or currency option (e.g., django-countries or django-money), because either of these would have well over a hundred entries (and my form happens to have both). Instead they would be loading these options via AJAX or using a different widget all together like an auto-complete. (I get it that a long list is not the best UX but that's a bit of a different discussion).

I vaguely remember having this issue when I moved to Django 1.11. It was frustrating. I have thus far refused to move over to Jinja, and I just use autocompletes for my large select widgets.
There is also the possibility of using template fragment caching. Wrap the select in a cache block, and it will loaded into memory once. See https://docs.djangoproject.com/en/1.11/topics/cache/#template-fragment-caching.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
django-users...@googlegroups.com.
To post to this group, send email to
django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e723ec8-be37-49cf-969e-5b484e3e5b65%40googlegroups.com.
To post to this group, send email to djang...@googlegroups.com.