#11476: Using delete on modelformset doesn't remove form from set ----------------------------------------------------------+----------------- Reporter: Michael Stevens <mstev...@etla.org> | Owner: nobody Status: closed | Milestone: Component: Forms | Version: SVN Resolution: wontfix | Keywords: Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ----------------------------------------------------------+----------------- Changes (by kmtracey):
* status: new => closed * needs_better_patch: => 0 * needs_tests: => 0 * needs_docs: => 0 * resolution: => wontfix Old description: > I'm using a ModelFormset created with lineformset_factory. > > When I click delete on one of the records and save the formset, it > successfully removes the associated db record, but if I redisplay the > formset after the save, it's still showing the now removed form. > > I've modified my code to recreate the formset from the db immediately > after the save: > {{ > if foo_formset.is_valid(): > foo_formset.save() > foo_formset = FooInlineFormset(instance=bar, prefix='foo') > }} > and it does what I expect, but shouldn't it be in the right state > after the save? > > Looking at the code I think the problem is that BaseModelFormSet > doesn't do anything with deleted forms after it deletes the underlying > model object - I'm expecting them to be removed from the formset as > well. > > I'm running a svn checkout of 1.1. New description: I'm using a !ModelFormset created with lineformset_factory. When I click delete on one of the records and save the formset, it successfully removes the associated db record, but if I redisplay the formset after the save, it's still showing the now removed form. I've modified my code to recreate the formset from the db immediately after the save: {{{ if foo_formset.is_valid(): foo_formset.save() foo_formset = FooInlineFormset(instance=bar, prefix='foo') }}} and it does what I expect, but shouldn't it be in the right state after the save? Looking at the code I think the problem is that !BaseModelFormSet doesn't do anything with deleted forms after it deletes the underlying model object - I'm expecting them to be removed from the formset as well. I'm running a svn checkout of 1.1. Comment: Fixed formatting. Please use preview, you need three brackets, not two, to embed code. This was answered on the mailing list as a problem with your expectations, not a bug in the code: http://groups.google.com/group/django- users/browse_thread/thread/97885473cb5b4ffd/ so I am not sure why you opened a ticket on it. If you disagree it would have been better to continue the conversation on the list. You have provided no new information/support for your viewpoint in this ticket so the answer here is the same. Re-displaying a form after successfully processing it is not an expected pattern, nor is it good design from a usability standpoint. Doing work to fix up the form data to reflect a delete is thus a waste of time for the normal case and enabling bad design. I don't believe we should do this. -- Ticket URL: <http://code.djangoproject.com/ticket/11476#comment:1> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---