Opened 17 years ago
Closed 14 years ago
#7439 closed New feature (fixed)
FormWizard don't process multipart forms
Reported by: | 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)
Change History (16)
by , 17 years ago
Attachment: | added_files_to_get_form_method.diff added |
---|
comment:1 by , 17 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
milestone: | → 1.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:4 by , 16 years ago
milestone: | 1.0 → post-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 , 16 years ago
Cc: | added |
---|
comment:7 by , 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 , 15 years ago
Cc: | added |
---|
by , 15 years ago
Attachment: | multipart_form_as_last_in_formwizard.diff added |
---|
add raise when multipart form is not as last
comment:9 by , 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 , 14 years ago
Keywords: | wizard added |
---|
comment:11 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:12 by , 14 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.
This patch still applies cleanly.