Giter VIP home page Giter VIP logo

Comments (8)

JhonFrederick avatar JhonFrederick commented on July 29, 2024 3

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.

karlos-perez avatar karlos-perez commented on July 29, 2024 3

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.

andyp05 avatar andyp05 commented on July 29, 2024

I am seeing this as well with django 3.1

from django-dynamic-formset.

alfonsrv avatar alfonsrv commented on July 29, 2024

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.

systemallica avatar systemallica commented on July 29, 2024

Just here to add that indeed deleting (totalForms.val(forms.length);) from the code did the trick for me.

from django-dynamic-formset.

nick-tao avatar nick-tao commented on July 29, 2024

Thanks for this @pavlutom

I was having the same problem. Removing this line: totalForms.val(forms.length); solved the issue.

from django-dynamic-formset.

Yuri-Lima avatar Yuri-Lima commented on July 29, 2024

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.

Yuri-Lima avatar Yuri-Lima commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.