Hi,

I am using a ModelChoiceField in a simple FormSet (not a ModelFormSet). 
When rendering the FormSet, Django duplicates the ModelChoiceField queryset 
for each row of the FormSet and repeats the same query multiple times to 
fill the select boxes. Is there a standard solution to cache the 
ModelChoiceField queryset after the first query and re-use it for the rows 
2 to N ?

I have found these solutions 
<https://stackoverflow.com/questions/8176200/caching-queryset-choices-for-modelchoicefield-or-modelmultiplechoicefield-in-a-d>
 or 
this one 
<https://stackoverflow.com/questions/32082945/django-multiple-forms-with-modelchoicefield-too-many-queries>,
 
but they look like ugly hacks to me.

Any help appreciated!

-- 
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/2cb28dd1-c8da-42e7-999f-9e8e6d6d2130%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to