You would need to cache the queryset and pass it to each form instance that
the formset creates. I've done this a few different ways in the past. I've
never understood why there isn't a more straight forward way to do this.
Here's a post with a few legit options depending on your use case:

https://stackoverflow.com/questions/8176200/caching-queryset-choices-for-modelchoicefield-or-modelmultiplechoicefield-in-a-d

Hard to be more specific without knowing anything about your code.

On Fri, Feb 25, 2022, 8:53 PM Steve Smith <[email protected]>
wrote:

> If in fact I am….how do I avoid this?  I have been playing with
> alternatives for a week and I’m starting to lose it…lol
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows
>
>
>
> *From: *Jacob Greene <[email protected]>
> *Sent: *Friday, February 25, 2022 5:58 PM
> *To: *[email protected]
> *Subject: *Re: Slow page load performance with a large number of formsets
> (over 25)
>
>
>
> If you're using model choice fields, it's very likely you are making an
> SQL query for each form set. It should be pretty obvious in the log with
> debug turned on.
>
>
>
> On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski <[email protected]> wrote:
>
> Steven, are you using ModelFormSet?  If so, Is it the initial query
> that's slow?  The form rendering?  Or is it the POST back to the server
> that's slow?  You can use django-debug-toolbar[1] to profile your page
> and get these metrics.
>
> Once you figure out what part is slowest, then you can optimize.
>
> Hope this helps!
>
> Ryan N
>
> [1] https://django-debug-toolbar.readthedocs.io/en/latest/
>
> On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> > Did this issue ever get resolved?  I'm experiencing the same thing.
> Once
> > it hits 100 forms or so it gets pretty slow.
> >
> > On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
> >
> > > Yes, if you want speed, using javascript and ajax is probably your
> best
> > > bet. It will probably also reduce merge-conflicts.
> > >
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com
> .
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com
> <https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De4E3zFuzmK_UOf9exaEc5pM5FNun7xJXhn_yVbHyWqiWg%40mail.gmail.com.

Reply via email to