Open pavlutom opened 4 years ago
I am seeing this as well with django 3.1
Thank god. I could not delete any formset form but the first one because of this line.
Hidden and therefore deleted rows still have to be enumerated in the management header's TOTAL_FORMS
, as Django will only consider that amount for rows. Any rows surpassing this value will be disregarded. E.g. if you have two forms and you schedule one for deletion, TOTAL_FORMS
updates to 1
, which will then in turn result in the second form to be ignored by Django completely.
Reviewing #173, it seems like the author did not implement the library properly into his project, as decrementing beyond the specified amount of min_num
is not possible. It is to note that this is mainly due to a sloppy documentation, as django-dynamic-formset
not only requires formCssClass
to be unique, but also addCssClass
, deleteCssClass
and possibly even deleteContainerClass
. This may be due to an improperly setup selector in the library, but that's at least the current requirement/behavior.
If I delete one item and create another in one POST, the new item is not created, only the deletion happens. It works fine if I remove line 95 in src/jquery.formset.js (
totalForms.val(forms.length);
). This code was introduced in #173. I'm not sure what was the purpose of this line, probably to fix some other error that I didn't notice.I am using Django 3.0.7
I had the same problem, I spent hours looking for the problem and as you mention everything works fine for me if the line 95 src/jquery.formset.js (totalForms.val(forms.length);)
is removed, I regard that code should be removed and another solution should be looked if it was introduced to fix some error.
I solved this problem without deleting the code. I assigned unique CSS class name to formCssClass for each formset as in Django Dynamic Formsets documentation:
$(".inline.{{ log_form.prefix }}").formset({
prefix: '{{ log_form.prefix }}',
formCssClass: 'dynamic-formset-{{ log_form.prefix }}'
})`
Just here to add that indeed deleting (totalForms.val(forms.length);)
from the code did the trick for me.
Thanks for this @pavlutom
I was having the same problem. Removing this line: totalForms.val(forms.length); solved the issue.
For god Sake, guys. Thanks Million for that solution. Removing the line 95 has working PERFECT. It save me a lot time.
Thanks Million Again.
I solved this problem without deleting the code. I assigned unique CSS class name to formCssClass for each formset as in Django Dynamic Formsets documentation:
$(".inline.{{ log_form.prefix }}").formset({
prefix: '{{ log_form.prefix }}',
formCssClass: 'dynamic-formset-{{ log_form.prefix }}'
})`
@karlos-perez, your solution probably has been working. but maybe you didn't understand what was the main issue. Not sure of course. I'm just saying it because i was trying to solve using so many ways from Django tools, but i do realize that problem came from the JS file. So, up to now. I do recommend use the solution which those guys have discovered. Anyway thanks @karlos-perez
If I delete one item and create another in one POST, the new item is not created, only the deletion happens. It works fine if I remove line 95 in src/jquery.formset.js (
totalForms.val(forms.length);
). This code was introduced in https://github.com/elo80ka/django-dynamic-formset/pull/173. I'm not sure what was the purpose of this line, probably to fix some other error that I didn't notice.I am using Django 3.0.7