This was one of those bugs where you search for hours, endlessly, only to

arrive at a simple, senseful and elegant solution that costs only 3 lines to
implement.

I know I should be happy about that, but it really makes me feel like a
total dumbass.
main
Jaap Joris Vens 2020-03-19 18:59:29 +01:00
rodzic 764f135785
commit 9a8822f68b
1 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -84,9 +84,14 @@ class SectionForm(forms.ModelForm):
def is_valid(self):
result = super().is_valid()
if self.is_bound:
for formset in self.formsets:
result = result and formset.is_valid()
for formset in self.formsets:
result = result and formset.is_valid() # AND
return result
def has_changed(self):
result = super().has_changed()
for formset in self.formsets:
result = result or formset.has_changed() # OR
return result
def save(self, commit=True):