Hi Collin,
On Tuesday, November 25, 2014 7:08:07 AM UTC+5:30, Collin Anderson wrote:
-- Thanks for taking time out to look at this. It turns out that I somehow I copied the rendered HTML wrong! The real problem was that the form id used in input was incorrect and this was the reason for the file not getting uploaded.
Separately, this is not really a trick but a fairly standard technique nowadays, and after correcting my mistake, it works just fine.
Thanks,
Abhishek
On Tuesday, November 25, 2014 7:08:07 AM UTC+5:30, Collin Anderson wrote:
Hi,I certainly am learning something new about <input form="id_of_form">. However, it may be that that trick simply doesn't work correctly for file fields. My question is: _does_ it work correctly when the <input> is a child of the <form>?Collin
On Saturday, November 22, 2014 1:21:32 PM UTC-5, Abhishek Batra wrote:Hey Donarb,Input fields are not required to be inside form elements, so long as they specify the form attribute as I have done. Check the form attribute here for reference.Moreover, I have other input fields as well which are outside the form element, but they get successfully submitted.Any other suggestions anyone?Thanks,Abhishek
On Saturday, November 22, 2014 11:03:39 PM UTC+5:30, donarb wrote:On Friday, November 21, 2014 7:56:54 PM UTC-8, Abhishek Batra wrote:Hi,
This is probably not a Django issue, but just trying my luck.I have an
input
field corresponding to a DjangoImageField
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 anUpdateView
. I foundrequest.FILES
to be empty andrequest.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 BatraThe input field is outside the closing </form> tag so would not be uploaded as part of the form.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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.
No comments:
Post a Comment