Opened 16 years ago

Closed 13 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@…, philipp.bosch@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

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@…> 16 years ago.
multipart_form_as_last_in_formwizard.diff (2.6 KB ) - added by makoste 15 years ago.
add raise when multipart form is not as last

Download all attachments as: .zip

Change History (16)

by Damian Świstowski <damian@…>, 16 years ago

comment:1 by Jeff Anderson, 16 years ago

Needs documentation: set
Triage Stage: UnreviewedAccepted

comment:2 by mcroydon, 16 years ago

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

comment:3 by mcroydon, 16 years ago

Owner: changed from mcroydon to nobody
Status: assignednew

This patch still applies cleanly.

comment:4 by Jacob, 16 years ago

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 by stryderjzw, 16 years ago

Cc: stryderjzw@… added

comment:6 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:7 by Marc Fargas, 16 years ago

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 by anonymous, 15 years ago

Cc: philipp.bosch@… added

by makoste, 15 years ago

add raise when multipart form is not as last

comment:9 by anonymous, 15 years ago

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 by Russell Keith-Magee, 14 years ago

Keywords: wizard added

comment:11 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

comment:12 by oluwaseun, 13 years ago

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 by steph, 13 years ago

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

comment:14 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

Superseded by #9200.

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