Re: use of save_FOO_file
Hi Franchesco There is a patch for newforms using the fileInput widget correctly. there you can find it: When the browser has presented it's File dialog and the form is submitted with a file selected, the raw contents of the file is appended to the post request (you have to set the encoding parameter of the form tag accordingly). the method stores the raw contents from this post request to the file field. Am Sonntag, 3. Juni 2007 18:04 schrieb cesco: > In the following method available for FileFields: > > save_FOO_file(filename, raw_contents) > > what does "raw_contents" represents? > I didn't find any example on the web about it. > > Many thanks > Francesco > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use of save_FOO_file
Well, I'm really not sure what you've got going on. You definitely need enctype="multipart/form-data" for it to work. Have you tried saving a file in the default admin for the model? If so, does it work as expected? If not, maybe you have MEDIA_ROOT set wrong. Also try simplifying your form to make sure there's nothing wrong there. Try: {{ form }} I'm really not coming up with anything else, but maybe you could post more of your code for the view and the template. On Jun 3, 3:30 pm, cesco <[EMAIL PROTECTED]> wrote: > On Jun 3, 6:52 pm, sansmojo <[EMAIL PROTECTED]> wrote: > > > The raw, binary data of the file. After uploading, it ends up at > > request.FILES['file']['content'] (where 'file' is the name of your > > form field). > > > An example: > > > if request.FILES.has_key('file'): > > new_file = File(some_field='some_val', > > date_uploaded=datetime.now()) > > new_file.save_file_file(request.FILES['file']['filename'], > > request.FILES['file']['content']) # because the field name is file > > new_file.save > > Thanks for the reply but I still can't get it to work. > In the form.py I have the following code: > > class AddOfferForm(forms.Form): >picture = forms.CharField(widget=forms.FileInput()) >... > > and in the template I have: > > > > {{ form.picture }} > > > > and in the view.py I do > print request.FILES > but it's always empty (unlike request.POST which gives the expected > values). > > I tried also to include the following in the form: > enctype="multipart/form-data" > and to have {{ form.picture_file }} beside {{ form.picture }} as > pointed out here:http://www.djangoproject.com/documentation/forms/ > but the request.FILES was still empty. > > Do you have any idea on what's wrong? > > Any help would be very appreciated. > > Thanks and regards > Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use of save_FOO_file
On Jun 3, 6:52 pm, sansmojo <[EMAIL PROTECTED]> wrote: > The raw, binary data of the file. After uploading, it ends up at > request.FILES['file']['content'] (where 'file' is the name of your > form field). > > An example: > > if request.FILES.has_key('file'): > new_file = File(some_field='some_val', > date_uploaded=datetime.now()) > new_file.save_file_file(request.FILES['file']['filename'], > request.FILES['file']['content']) # because the field name is file > new_file.save Thanks for the reply but I still can't get it to work. In the form.py I have the following code: class AddOfferForm(forms.Form): picture = forms.CharField(widget=forms.FileInput()) ... and in the template I have: {{ form.picture }} and in the view.py I do print request.FILES but it's always empty (unlike request.POST which gives the expected values). I tried also to include the following in the form: enctype="multipart/form-data" and to have {{ form.picture_file }} beside {{ form.picture }} as pointed out here: http://www.djangoproject.com/documentation/forms/ but the request.FILES was still empty. Do you have any idea on what's wrong? Any help would be very appreciated. Thanks and regards Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use of save_FOO_file
The raw, binary data of the file. After uploading, it ends up at request.FILES['file']['content'] (where 'file' is the name of your form field). An example: if request.FILES.has_key('file'): new_file = File(some_field='some_val', date_uploaded=datetime.now()) new_file.save_file_file(request.FILES['file']['filename'], request.FILES['file']['content']) # because the field name is file new_file.save --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
use of save_FOO_file
In the following method available for FileFields: save_FOO_file(filename, raw_contents) what does "raw_contents" represents? I didn't find any example on the web about it. Many thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---