Re: Access to field name in upload_to?

2010-10-26 Thread Scott Gould
> One idea would be to put 'fieldname' as the first parameter to the > function, then use functools.partial [1] to create partial functions > for each file field with the value set appropriately: > >         thumbnail_image = FileField(upload_to=partial(get_upload_path, > 'thumbnail_image')) Outst

Re: Access to field name in upload_to?

2010-10-26 Thread Daniel Roseman
On Oct 26, 4:29 pm, Scott Gould wrote: > Hi folks, > > I've got all my file uploads (that go to S3 as it happens, but I don't > think that's overly important) taking their path from one upload_to > delegate: > > def get_upload_path(instance, filename=None): >         """ >         Defaults to appn

Access to field name in upload_to?

2010-10-26 Thread Scott Gould
Hi folks, I've got all my file uploads (that go to S3 as it happens, but I don't think that's overly important) taking their path from one upload_to delegate: def get_upload_path(instance, filename=None): """ Defaults to appname/modelname/uuid. """ return "%s/%s/%s