I may be missing something but lets say when you pass a string to "upload_to" it functions basically as it does now, however, if you pass a callable it takes the return value (the full relative path of the file, including the filename, in relation to MEDIA_ROOT) and splits it into the path and filename using os.path.split. my_file = models.FileField(upload_to=get_file_path)
def get_file_path(obj, filename): return "%s/%s/%s" % (datetime.now.strftime("%Y/%m/%d"), obj.id, filename) - Justin On 10/28/07, Marty Alchin <[EMAIL PROTECTED]> wrote: > > > On 10/27/07, Justin Driscoll <[EMAIL PROTECTED]> wrote: > > Any reason not to have upload_to accept a string OR a callable and > function > > accordingly? > > Hrm, to be honest, I hadn't really considered that. To me, upload_to > makes the most sense as a directory path only, rather than including a > filename. Especially since, how would we be able to tell whether > upload_to specifies a filename or a directory? We have to know if > we're supposed to replace the original filename or append it to a > path. If you have any ideas on how to do that, I'm all ears. > > -Gul > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers?hl=en -~----------~----~----~----~------~----~------~--~---