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
-~----------~----~----~----~------~----~------~--~---

Reply via email to