Ticket #17988: model_formset_check_commit_before_delete.diff

File model_formset_check_commit_before_delete.diff, 598 bytes (added by rem, 3 years ago)

Check commit=True before deleting existing objects.

  • django/forms/models.py

     
    607607            obj = self._existing_object(pk_value)
    608608            if self.can_delete and self._should_delete_form(form):
    609609                self.deleted_objects.append(obj)
    610                 obj.delete()
     610                if commit:
     611                    obj.delete()
    611612                continue
    612613            if form.has_changed():
    613614                self.changed_objects.append((obj, form.changed_data))
Back to Top