[Answered ]-Django disable widget caching?

2πŸ‘

βœ…

I don’t see this caching behavior when I do something similar with a ModelChoiceField.
It’s default widget is a Select.

Something like:

retailer = forms.ModelChoiceField(queryset=Retailer.objects.all())

When your code is evaluated, that choices parameter is constructed once and then your select just has a static list of retailer (id,name) tuples. When the ModelChoiceField is constructed, it is referencing a QuerySet which is not evaluated until the list of choices is actually requested/displayed.

πŸ‘€Daniel Rucci

Leave a comment