Re: Ticket #3297 & Newforms Image Uploading
On Jun 23, 2:41 pm, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > for n in range(0, MAX_NUM_UPLOADS): > > img_manip = ImageAttachment.AddManipulator() > > img_obj = img_manip.save() > > uploaded = clean_data['img_fld%d' % n] > > obj.save_image_file(uploaded['filename'], uploaded['content']) > > What library did you have to import to get ImageAttachment to work? Hah, sorry my bad... didn't know ImageAttachment was your model class. -_-; --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
> for n in range(0, MAX_NUM_UPLOADS): > img_manip = ImageAttachment.AddManipulator() > img_obj = img_manip.save() > uploaded = clean_data['img_fld%d' % n] > obj.save_image_file(uploaded['filename'], uploaded['content']) What library did you have to import to get ImageAttachment to work? --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
On 6/23/07, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > > Can't paste the code from the actual app (am under NDA) but the logic > > in saving the image from form data is here: > > > > http://dpaste.com/12731/ > > The only problem with this, and probably why I'm looking to use #3297 > (which actually didn't work too well anyway), is because I have as > many as 15 file upload fields on one page. All the examples I've seen > only take care of one image on a certain form at a time and I don't > want to duplicate the code up to 15 times. BTW, Had a typo in the dpaste code. Line 19 should say: img_obj.save_image_file(uploaded['filename'], uploaded['content']) You don't have to duplicate code, well not duplicate too much. That's why the image validation method in the form is separate from the *_clean methods. In my app, I had to allow up to four simultaneous uploads. You have to set a limit to the number of uploads because if you don't you will be bound to hit the limits of your server anyway. Create a form with the number of image fields numbered in sequence. For example: img_fld1 img_fld2 img_fld3 ... Then when you do your processing in your view, simply wrap the code that saves the images in a loop: for n in range(0, MAX_NUM_UPLOADS): img_manip = ImageAttachment.AddManipulator() img_obj = img_manip.save() uploaded = clean_data['img_fld%d' % n] obj.save_image_file(uploaded['filename'], uploaded['content']) For validation, I haven't tried it yet, but I think you should be able to implement it using __getattr__ to handle it. That way you don't have to duplicate validation code. -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
> Can't paste the code from the actual app (am under NDA) but the logic > in saving the image from form data is here: > > http://dpaste.com/12731/ The only problem with this, and probably why I'm looking to use #3297 (which actually didn't work too well anyway), is because I have as many as 15 file upload fields on one page. All the examples I've seen only take care of one image on a certain form at a time and I don't want to duplicate the code up to 15 times. --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
On 6/22/07, Dirk van Oosterbosch, IR labs <[EMAIL PROTECTED]> wrote: > This is what I did for the field validation http://dpaste.com/12715/ > > the code to save the field data is in the view that uses this form. > Nice! Would you maybe be willing to share your view code too? Can't paste the code from the actual app (am under NDA) but the logic in saving the image from form data is here: http://dpaste.com/12731/ Oh, and make sure you add the following enctype attribute to your form: ... -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
On 22-jun-2007, at 6:22, Nimrod A. Abing wrote: > I have managed to do > so either by processing in the view or extending the form. As of now, > all processing of all forms occur in the view and validation for file > and image fields in a method of the form. > > This is what I did for the field validation http://dpaste.com/12715/ > the code to save the field data is in the view that uses this form. Nice! Would you maybe be willing to share your view code too? Thnx dirk --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
> You can always write the code to process File/Image fields in the view > or just extend your form to handle them properly. I have managed to do > so either by processing in the view or extending the form. As of now, > all processing of all forms occur in the view and validation for file > and image fields in a method of the form. > > This is what I did for the field validationhttp://dpaste.com/12715/ > the code to save the field data is in the view that uses this form. > > There is also a recent thread discussing this very same issue. There > are also good solutions there so check them out. > > HTH. Thanks Nimrod. I'll check that out. But your code looks like something I'd use too. :) --~--~-~--~~~---~--~~ 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: Ticket #3297 & Newforms Image Uploading
On 6/22/07, Bryan Veloso <[EMAIL PROTECTED]> wrote: > > RE: http://code.djangoproject.com/ticket/3297 > > I'm wondering if anybody has actually used this patch for a production > site. If not, then I'll put off a certain feature of my site until > later. The patch is really tempting though, so I wanted to get a > better outlook of experiences before taking the leap. You can always write the code to process File/Image fields in the view or just extend your form to handle them properly. I have managed to do so either by processing in the view or extending the form. As of now, all processing of all forms occur in the view and validation for file and image fields in a method of the form. This is what I did for the field validation http://dpaste.com/12715/ the code to save the field data is in the view that uses this form. There is also a recent thread discussing this very same issue. There are also good solutions there so check them out. HTH. -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---