Comments (8)
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.
from django-dynamic-formset.
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 }}'
})`
from django-dynamic-formset.
I am seeing this as well with django 3.1
from django-dynamic-formset.
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.
from django-dynamic-formset.
Just here to add that indeed deleting (totalForms.val(forms.length);)
from the code did the trick for me.
from django-dynamic-formset.
Thanks for this @pavlutom
I was having the same problem. Removing this line: totalForms.val(forms.length); solved the issue.
from django-dynamic-formset.
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.
from django-dynamic-formset.
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
from django-dynamic-formset.
Related Issues (20)
- delete link doesn't show and formCount is NaN HOT 4
- Uncaught ReferenceError: deleteButtonHTML is not defined
- No remove button and add won't add form HOT 3
- I have installed django_dynamic_formsets but it says the module not installed dynamic_formsets. I'm using windows 10 with python version 3.8.5.
- Limit minimum and maximum of formsets
- Nested formsets HOT 1
- Demo package download link is down
- Is it possible to include html inside addText or deleteText? HOT 4
- nothing
- deleteContainerClass does not seem to be working
- Only rows specified in 'extra' are saved and rows above 'extra' do not have default values
- deleteContainerClass not working properly HOT 1
- how to use onKeyup for django formset input fields
- delete button shows up only once in django formset that is created with queryset to edit
- Clicking on add row in update mode displays foreign keys even if label is none. HOT 1
- Input field id show NaN instead of increased number even with prefix set HOT 6
- does not seem to work with file fields HOT 1
- Deleting instance not working when hideLastAddForm is true HOT 1
- Unsetting and resetting the current formset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-dynamic-formset.