Opened 15 years ago

Closed 12 years ago

#7439 closed New feature (fixed)

FormWizard don't process multipart forms

Reported by: Damian Świstowski <damian@…> Owned by: nobody
Component: contrib.formtools Version: dev
Severity: Normal Keywords: wizard
Cc: stryderjzw@…,… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no


get_form method creating form only with request.POST parameter, adding request.FILES resolves problem.

Attachments (2)

added_files_to_get_form_method.diff (2.2 KB) - added by Damian Świstowski <damian@…> 15 years ago.
multipart_form_as_last_in_formwizard.diff (2.6 KB) - added by makoste 13 years ago.
add raise when multipart form is not as last

Download all attachments as: .zip

Change History (16)

Changed 15 years ago by Damian Świstowski <damian@…>

comment:1 Changed 15 years ago by Jeff Anderson

Needs documentation: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 15 years ago by mcroydon

milestone: 1.0
Owner: changed from nobody to mcroydon
Status: newassigned

comment:3 Changed 15 years ago by mcroydon

Owner: changed from mcroydon to nobody
Status: assignednew

This patch still applies cleanly.

comment:4 Changed 14 years ago by Jacob

milestone: 1.0post-1.0
Needs tests: set
Patch needs improvement: set

This is a borderline feature addition, and without tests I'm reluctant to check it in this late. I'm going to push post-1.0; if someone can get a (passing) test written by 8/30, pop this back to the 1.0 milestone and I'll check it in.

comment:5 Changed 14 years ago by stryderjzw

Cc: stryderjzw@… added

comment:6 Changed 14 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:7 Changed 14 years ago by Marc Fargas

This thing should be documented somehow, documentation reads (now):
"""Important limitation: Because the wizard uses HTML hidden fields to store data between pages, you may not include a FileField in any form except the last one."""

I'd say you cannot include a FileField on *any* form neither the last one, as request.FILES never gets passed around. Until this gets fixed we should tell people that their files will be left in limbo! ;)

(Or I did something really bad and I should really be getting my files on the last form! :)

comment:8 Changed 13 years ago by anonymous

Cc:… added

Changed 13 years ago by makoste

add raise when multipart form is not as last

comment:9 Changed 13 years ago by anonymous

Perhaps I did something wrong, but when I tried implementing the patches (by overriding get_form and call in my FormWizard subclass), I get a "Please upload a valid image. The file you uploaded was either not an image or a corrupted image." error every time with an ImageField.

comment:10 Changed 12 years ago by Russell Keith-Magee

Keywords: wizard added

comment:11 Changed 12 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:12 Changed 12 years ago by oluwaseun

Easy pickings: unset

Now I just did a hack and maybe this might help somebody

Line 117: f = self.get_form(i, request.POST)
Change to: f = self.get_form(i, request.POST, request.FILES)

Line 131: form = self.get_form(current_step, request.POST)
Change to: form = self.get_form(current_step, request.POST, request.FILES)

Line 46 of the get_form method: def get_form(self, step, data=None)
Change the signature to: def get_form(self, step, post=None, files=None):

Then you should be fine.But there's a caveat though, your file must be on the last form also you cannot have two select options on the same page.
I don't know why that is a problem. Still checking whats is wrong. Also I would love to know if anyone has been able to make the form go back i.e. using a previous and next button. I'm working on that now though but if someone has fixed that. Would be glad to know.
I hope this helps somebody.

comment:13 Changed 12 years ago by steph

See #9200. The features requested here will be solved with the patch in #9200.

comment:14 Changed 12 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

Superseded by #9200.

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