1👍
✅
You can iterate over the formset.deleted_forms
:
for form in formset.deleted_forms:
if form.instance.pk:
form.instance.delete()
As alternative you can check for DELETE
key in the cleaned_data
:
for job_form in formset:
if job_form.is_valid():
if job_form.cleaned_data.get('DELETE') and job_form.instance.pk:
job_form.instance.delete()
else:
instance = job_form.save(commit=False)
instance.account = account
instance.save()
Source:stackexchange.com