I am trying to pass a custom upload_to function to my imageField models, but I would like to define the function as a model function .... is this possible?
class MyModel(models.Model): ... image = models.ImageField(upload_to=self.get_image_path) ... def get_image_path(self, filename): ... return image_path
Now I know that I can not refer to it as "I", since I myself do not exist at this moment ... is there a way to do this? If not, where is the best place to define this function?
source share