Trying to save a bunch of objects but with a custom form:
class CustomForm(forms.ModelForm):
class Meta:
model = Widget
complexify = models.BooleanField()
When complexify is checked, i need to do some complex operations on the widget object.
I can’t do:
for object in formset.save(commit=False):
...
because it won’t have the complexify flag.
And going through each form seems to be the wrong way:
for form in formset.forms:
...
because it includes the extra (empty) forms and the deleted forms.
Any ideas on how to get this done?
The best answer i could find to this problem was overriding the
saveon the form:then it will be available for you when you handle them: