Let's say i have many models like that:
class ExampleModel(models.Model):
photo = models.ImageField(upload_to='photos/')
image = models.ImageField(upload_to='images/')
class AnotherExampleClass(models.Model):
another_image = models.ImageField(upload_to='another_images/')
So, it's many different models with ImageFields, which have different field names. What i want, is to somehow override all upload_to
like that:
upload_to = '%s/%s' % (upload_to, self.id)
for instance, if i upload picture to another_image
field, file path would be:
'another_images/1/picture.jpg'
I realize that i need to create some CustomImageField
based on models.ImageField
. But how exactly achive that with minimal pain?