Code

Opened 5 years ago

Closed 5 years ago

#11476 closed (wontfix)

Using delete on modelformset doesn't remove form from set

Reported by: Michael Stevens <mstevens@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by kmtracey)

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.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.