> 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
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
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
3 matches
Mail list logo