views:

29

answers:

1

I have an abstract Django model and I want to define an ImageField inside of it. The problem is that when I do define it, it raises an error because I don't have an "upload_to" attribute. Is there a way to still define it and have a separate folder for each inheriting class?

A: 

upload_to can be a callable.

image=models.ImageField(upload_to=my_callable)

where callable is something like this:

def my_callable(instance,filename):
    path='sth depending on class name'
    return path
Till Backhaus