On 8/15/06, Nathan Ekstrom <[EMAIL PROTECTED]> wrote: > > Hey all, > I've tried searching the list for this but I probably don't know the > right key words to use. What I would like to do is customize the > behavior of the ImageField and FileField of models. Instead of saving > to media/<date stuff>/<image name> I'd like to be able to save it to a > custom directory dependant on another field in the row
Hi Nathan, I think you'll probably need to use a custom field type -- it's pretty much built in to FileField and ImageField that the user-supplied filename is the name to save the file under on disk. What I've done, solve a problem like this, is to subclass ImageField, and override the save_file method to change the filename in the incoming data on file upload. Check out http://www.verdjn.com/wiki/PhotoField -- we use the field name, and the object's primary key to make up the filename before it gets saved. > also in the > case of an image I would like to generate some thumbnails and save them > to different directories. Is there a way to do this with the admin > interface or will I need to do it another way. Incidentally, our PhotoField class also supports thumbnail generation, although we generate them dynamically, rather than saving them at upload time. Regards, Ian Clelland <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---