Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#19880 closed Bug (fixed)

form-wizard initial data example is wrong

Reported by: almalki Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords: form-wizard formwizard wizard
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In this example there is a small error, basically it is calling as_view and then call methods on the returned function.

>>> wiz = ContactWizard.as_view([ContactForm1, ContactForm2], initial_dict=initial)
>>> form1 = wiz.get_form('0')

should be:

>>> wiz = ContactWizard([ContactForm1, ContactForm2], initial_dict=initial)
>>> form1 = wiz.get_form('0')

(assuming __init__ takes same arguments as as_view)

Attachments (1)

19880.diff (879 bytes) - added by Tim Graham 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by Carl Meyer

Triage Stage: UnreviewedAccepted

comment:2 Changed 4 years ago by Carl Meyer

#19886 was a duplicate.

comment:3 Changed 4 years ago by expleo

comment:4 Changed 4 years ago by expleo

Has patch: set

comment:5 Changed 4 years ago by Tim Graham

Has patch: unset

Whoops, I had meant to comment on this but I left the comment on the duplicate ticket instead.

You can't initialize ContactWizard directly with a list of forms and the initial dict. The as_view call is correct, but then you need to pass request to the function that's returned. Maybe RequestFactory could be used for the example, but a session is also needed on the request so it seems a bit complicated to have this example use the shell.

comment:6 in reply to:  5 Changed 4 years ago by expleo

Replying to timo:

Whoops, I had meant to comment on this but I left the comment on the duplicate ticket instead.

You can't initialize ContactWizard directly with a list of forms and the initial dict. The as_view call is correct, but then you need to pass request to the function that's returned. Maybe RequestFactory could be used for the example, but a session is also needed on the request so it seems a bit complicated to have this example use the shell.

I agree, not changing the docs seems the best option in this case.

Changed 4 years ago by Tim Graham

Attachment: 19880.diff added

comment:7 Changed 4 years ago by Tim Graham

Has patch: set

I think we should make some sort of fix since it's misleading as is. How about the attached?

comment:8 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In a97c441e18684570fbecd47b19bd47b4c06cc565:

[1.5.X] Fixed #19880 - Fixed an error in the form wizard initial_dict example.

Thanks almalki for the report.

Backport of 9b97f01dea from master

comment:9 Changed 4 years ago by Tim Graham <timograham@…>

In 9b97f01dea093de484366924842c89550472d0b6:

Fixed #19880 - Fixed an error in the form wizard initial_dict example.

Thanks almalki for the report.

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