Hello John, Did you try switching to the Jinja2 form renderer[0] to see if it helps? I've not tried it myself but I heard it makes a significant difference.
Cheers, Simon [0] https://docs.djangoproject.com/en/2.1/ref/forms/renderers/#jinja2 Le vendredi 7 décembre 2018 08:30:48 UTC-5, John a écrit : > > My site <https://www.morphmarket.com/> 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: > > - Render/django/forms/widgets/select_option.html > - Render/django/forms/widgets/select.html > - Render/django/forms/widgets/attrs.html > > [image: xDE2A.png] > > This seems to be related to 1.11's change to Template-based Widget > Rendering <https://code.djangoproject.com/ticket/15667> (docs > <https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#djangotemplates>), > > 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). > > - Search Form > > <https://gist.github.com/jplehmann/b75379c12a37a6064f1face208d7dc88#file-search-py-L223> > - Search HTML > <https://gist.github.com/jplehmann/44872ab2c02da89080e9a199aed349ae> > - Live Site <http://www.morphmarket.com/> > > Thank you in advance for your help! > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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.