Given a form, I want to change a value on a field before it gets rendered. This is what I'm trying:
class RequiredFormSet(BaseFormSet):
def add_form(self):
tfc = self.total_form_count()
self.forms.append(self._construct_form(tfc))
if self.is_bound:
data = self.management_form.data.copy() # make data mutable
data[TOTAL_FORM_COUNT] = self.management_form.cleaned_data[TOTAL_FORM_COUNT] + 1
self.management_form.data = data
else:
self.extra += 1
I thought everything was stored in data
, but I guess that data
has been passed off to the individual fields (or widgets) already? So what property do I need to modify exactly?