Opened 13 years ago

Closed 13 years ago

#17677 closed Bug (fixed)

WizardView.get_form destroys 'instance' and 'queryset' from get_form_kwargs

Reported by: Gary Reynolds Owned by: nobody
Component: contrib.formtools Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

In the case where the wizard author might like to populate the form with an existing model instance or formset from a queryset based through get_form_kwargs it get's destroyed by a call to kwargs.update({'instance': self.get_form_instance(step)}) or kwargs.update({'queryset': self.get_form_instance(step)}).

While I can appreciate that there is already a way to populate this value by overloading the get_form_instance method, I don't think that we should be destructive of another way to achieve it. Additionally I find it less confusing if I can define all kwargs to be passed to my form/formset init method in one place (ie. in get_form_kwargs) rather than splitting this logic into two places.

I've attached a patch against r17511 which includes a test case.

Attachments (2)

17677.diff (5.2 KB ) - added by Gary Reynolds 13 years ago.
17677-2.diff (5.2 KB ) - added by steph 13 years ago.
Updated patch (some test changes)

Download all attachments as: .zip

Change History (4)

by Gary Reynolds, 13 years ago

Attachment: 17677.diff added

comment:1 by Jannis Leidel, 13 years ago

Needs documentation: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

by steph, 13 years ago

Attachment: 17677-2.diff added

Updated patch (some test changes)

comment:2 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [17651]:

Fixed #17677 -- Made sure the WizardView doesn't accidentally overwrite the instance or queryset form parameters when they are already set by the get_form_kwargs method. Thanks to goodtune and Stephan Jäkel.

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