Re: Dynamic ImageField
No worries, I'm just trying to make sense of all the options. : ) Nonetheless, is there any documentation on what I can get out of each field in the save_file method, or examples of how I can access the filename and directory where the file is being saved within this method? Marcin's first example works great for me when I check/create the directory structure before the save and perform resizing after the save, but I'm having trouble putting these actions into the overridden method (that whole DRY thing...). Also, I tried using ideas from the AutoImageField in Marcin's second example, but my image resizing seemed to be getting the wrong file_path and failing silently. For some examples, I wrote a get_upload_to method for dynamic uploading as such: def get_upload_to(self, field_attname): return 'img/user/%d/%s' % (random.randint(10, 99), self.id) and I tried getting the filename within the save_file method as such: file_name = os.path.join(settings.MEDIA_ROOT, getattr(new_object, self.attname)) Thanks for any help! On Nov 13, 11:30 am, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Nov 13, 2007 11:03 AM, Peter <[EMAIL PROTECTED]> wrote: > > > Also, is there a big reason to override this vs the _save_FIELD_file > > method as shown in this example: > >http://gulopine.gamemusic.org/2007/11/customizing-filenames-without-p... > > I'll admit, that post was thrown together in a hurry, in response to > several questions that I kept answering with "it'll be better when my > filestorage work makes it into trunk". I felt it was better to have > something out there in the meantime, and I didn't research what > solutions others had come up with. > > In my opinion, the FileField (or ImageField) subclass approach linked > by Marcin is much simpler and cleaner than my own, and requires much > less ugly hackery. > > That said, this should all get better when my filestorage work makes > it into trunk. ;) > > -Gul --~--~-~--~~~---~--~~ 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: Dynamic ImageField
On Nov 13, 2007 11:03 AM, Peter <[EMAIL PROTECTED]> wrote: > Also, is there a big reason to override this vs the _save_FIELD_file > method as shown in this example: > http://gulopine.gamemusic.org/2007/11/customizing-filenames-without-patching.html I'll admit, that post was thrown together in a hurry, in response to several questions that I kept answering with "it'll be better when my filestorage work makes it into trunk". I felt it was better to have something out there in the meantime, and I didn't research what solutions others had come up with. In my opinion, the FileField (or ImageField) subclass approach linked by Marcin is much simpler and cleaner than my own, and requires much less ugly hackery. That said, this should all get better when my filestorage work makes it into trunk. ;) -Gul --~--~-~--~~~---~--~~ 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: Dynamic ImageField
Thanks for posting the example links. Is there any documentation on "save_file" and what each field actually is for this method? I was using some random numbers in the folder creation and wanted to make sure the folders exist before I save the file. Also, is there a big reason to override this vs the _save_FIELD_file method as shown in this example: http://gulopine.gamemusic.org/2007/11/customizing-filenames-without-patching.html Regards, Peter On Nov 8, 11:26 pm, cschand <[EMAIL PROTECTED]> wrote: > Hi Marcin >It's working... Thankyou very much :) > > cschand > > On Nov 8, 6:46 pm, Marcin Mierzejewski <[EMAIL PROTECTED]> > wrote: > > > Hi, > > > Yes, you > > can:http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic... > > > Regards, > > Marcin > > > On Nov 8, 2:08 pm, cschand <[EMAIL PROTECTED]> wrote: > > > > Hi all, > > > Can we make dynamic ImageFields?uploadfile to /media/avatar/ > > > username or userid/- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Dynamic ImageField
Hi Marcin It's working... Thankyou very much :) cschand On Nov 8, 6:46 pm, Marcin Mierzejewski <[EMAIL PROTECTED]> wrote: > Hi, > > Yes, you > can:http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic...http://code.djangoproject.com/wiki/CustomUploadAndFilters > > Regards, > Marcin > > On Nov 8, 2:08 pm, cschand <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > Can we make dynamic ImageFields? upload file to /media/avatar/ > > username or userid/- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Dynamic ImageField
Hi, Yes, you can: http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/ http://code.djangoproject.com/wiki/CustomUploadAndFilters Regards, Marcin On Nov 8, 2:08 pm, cschand <[EMAIL PROTECTED]> wrote: > Hi all, > Can we make dynamic ImageFields? upload file to /media/avatar/ > username or userid/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---