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
Source:stackexchange.com