#14574 closed New feature (fixed)
Initial values support for inline model formsets
Reported by: | Simon Litchfield | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | inlineformset_factory BaseInlineFormSet BaseModelFormSet |
Cc: | Honza Král, claude@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
ModelFormSet allows the initial={} parameter, but InlineModelFormSet doesn't; simply because it's missing kwargs. Patch attached.
Attachments (4)
Change History (16)
by , 14 years ago
Attachment: | inlineformset-kwargs.diff added |
---|
comment:1 by , 14 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:2 by , 14 years ago
Has patch: | unset |
---|---|
Keywords: | BaseInlineFormSet BaseModelFormSet added; BaseInlineModelFormSet removed |
milestone: | 1.3 → 2.0 |
Summary: | Missing kwargs from inline formsets breaks initial support → Initial values support for model formsets |
Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 14 years ago
milestone: | 2.0 |
---|
comment:4 by , 14 years ago
I just ran into this today. I expected to be able to pass initial values into a BaseInlineFormSet that I got from an inlineformset_factory. It is useful for setting default values on unbound forms.
Also similar to #12213
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:6 by , 13 years ago
Easy pickings: | unset |
---|---|
Summary: | Initial values support for model formsets → Initial values support for inline model formsets |
UI/UX: | unset |
#16446 reported a manifestation of this in FormWizard
comment:7 by , 13 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Design decision needed → Accepted |
comment:8 by , 13 years ago
Patch needs improvement: | unset |
---|
I attached a starting point for supporting initial values for model formsets. If this approach and implementation is accepted, I might then work on tests and maybe adding an example to the doc.
comment:9 by , 13 years ago
Needs tests: | unset |
---|
This second patch is more elaborate, as it includes tests and also adds support for inline model formsets (taken from initial patch).
comment:10 by , 13 years ago
Cc: | added |
---|
comment:12 by , 13 years ago
I added ticket #17927, that is request for the same functionality for BaseGenericInlineFormSet
Sorry, broken patch. Using initial on ModelFormSet overrides queryset populated values.
If anyone else is interested in adding initial= support for *ModelFormSets, I'll happily patch. I'd expect the initial values to populate the extra (empty) forms only. If it's a single dictionary, repeat it on all extra forms; if it's multiple then apply in order.