Open HPJason opened 4 years ago
it still happen in django 3.1
Hello. I have the same problem? Did you find a solution?
I'm currently only using it for inline formsets within tables
I managed to fix the deletion problem by editing the source code, updating this part of code:
if (del.length) {
// We're dealing with an inline formset.
// Rather than remove this form from the DOM, we'll mark it as deleted
// and hide it, then let Django handle the deleting:
del.val('on');
row.hide();
forms = $('.' + options.formCssClass).not(':hidden');
totalForms.val(forms.length);
}
To this:
if (del.length) {
// We're dealing with an inline formset.
// Rather than remove this form from the DOM, we'll mark it as deleted
// and hide it, then let Django handle the deleting:
del.val('on');
row.hide();
forms = $('.' + options.formCssClass);
totalForms.val(forms.length);
}
I was getting a weird behavior when deleting several items because by excluding the hidden rows (marked as deleted) from the totalForms
count, Django's formset apis wasn't processing the deletion properly.
Having same issue with Django 1.11 and above changes is not helping. @vitorfs
seems like we should not change totalForms
count on deletion.
I am using django 3.0.2.
Any idea to fix it, thanks.