I have an input
field corresponding to a Django ImageField
in a Django template. Rendered, the HTML looks like:
<form action="/accounts/username/"
method="post"
id="profile_form"
enctype="multipart/form-data">
</form>
... (other input fields and elements)
<input form="profile_form" id="id_profile_pic" name="profile_pic" type="file" />
The corresponding View
is an UpdateView
. I found request.FILES
to be empty and request.cleaned_data
to contain 'profile_pic':
None
.
I used firebug to track the POST data. It contained other fields but not profile_pic
.
Can anyone say why the file does not get uploaded? I've posted this question to StakOverflow as well, in case someone wants reputation points.
Thanks,
Abhishek Batra
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aea0cc13-0b33-4734-b59f-a4f06ae12c14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
An input can only be associated with one form.
Abhishek,
Good tip about the <input form="..."> syntax! I didn't realize
you could do that to avoid having to nest the <input> fields
inside the <form>.
I just looked it up at:
- http://www.w3schools.com/tags/att_input_form.asp
where it says 2 interesting things:
- Not supported in IE
- Can specify multiple forms that the same input field is
a part of, so presumably, the field would be POSTed with
any of the listed forms. Rest of the page does not make
it obvious how to do that though. Value is a string of
space-separated form ids perhaps?
Any comment of either of these 2? Have you tried your app
on IE? Have you tried specifying multiple forms?
Thanks!