diff --git a/ippisite/ippidb/forms.py b/ippisite/ippidb/forms.py index ec1fdaf1a7d35654160835dc0d7879635c0c2de6..44583cc4b606960e483a0ffc8593c15e519d210d 100644 --- a/ippisite/ippidb/forms.py +++ b/ippisite/ippidb/forms.py @@ -527,6 +527,12 @@ class TestActivityDescriptionForm(forms.ModelForm): 'ppi': forms.HiddenInput(), } + def has_changed(self): + #If only the delete button was checked, and there is no id, it has not changed and thus should be ignored. + if len(self.changed_data) == 1 and self.changed_data[0] == "DELETE" and self.data.get("id", None) is None: + return False + return super().has_changed() + class CompoundActivityResultForm(ModelForm): class Meta: @@ -536,6 +542,12 @@ class CompoundActivityResultForm(ModelForm): 'activity', ) + def has_changed(self): + #If only the delete button was checked, and there is no id, it has not changed and thus should be ignored. + if len(self.changed_data) == 1 and self.changed_data[0] == "DELETE" and self.data.get("id", None) is None: + return False + return super().has_changed() + CompoundActivityResultInlineFormset = inlineformset_factory( parent_model=TestActivityDescription,