Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#9284 closed (fixed)

BaseModelFormSet and BaseInlineFormSet should call when saving objects

Reported by: drozzy@… Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by jkocherhans)

The most current code is at

This introduces some backwards incompatibilities for people who overrode either type of formset's __init__ method, but this is how I would have written the model formset code if we'd actually had modelforms first. This doesn't really solve any specific problems that I know of.

Attachments (1)

9284.diff (16.7 KB) - added by jkocherhans 9 years ago.
Fixed a typo

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by Malcolm Tredinnick

Resolution: invalid
Status: newclosed

Child forms don't always have enough information to save themselves in the situation when you're adding related elements to some other model: the related elements need to know which related model id to use, for example. If you look at the logic in model formsets (and you're only talking about model formsets here, since normal formsets don't have a save() method), you'll see that there's quite a bit of interaction between information that exists only on the formset object and the forms itself.

If you can come up with some patch that works in all cases and is obviously neater than the current code, then reopen the ticket, but this is currently a bit too ill-defined to be a ticket we can resolve.

comment:2 Changed 9 years ago by jkocherhans

Description: modified (diff)
Has patch: set
Resolution: invalid
Status: closedreopened
Summary: Formsets don't call form's saveBaseModelFormSet and BaseInlineFormSet should call when saving objects
Triage Stage: UnreviewedDesign decision needed

Changed 9 years ago by jkocherhans

Attachment: 9284.diff added

Fixed a typo

comment:3 Changed 9 years ago by jkocherhans

Resolution: fixed
Status: reopenedclosed

(In [10190]) Fixed #9284. Fixed #8813. BaseModelFormSet now calls
This is backwards-incompatible if you were doing things to 'initial' in BaseModelFormSet.init, or if you relied on the internal _total_form_count or _initial_form_count attributes of BaseFormSet. Those attributes are now public methods.

comment:4 Changed 9 years ago by jashugan

This looks excellent. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top