Here is a simple model:
class Product(models.Model):
caption = models.CharField(max_length=1000)
description=models.TextField()
supplier = models.ForeignKey(Supplier)
designNumber = models.CharField(max_length=100)
price = models.IntegerField()
stock = models.IntegerField()
parameters = models.ManyToManyField(ProductParameterValues)
image = cloudinary.models.CloudinaryField('image')
added_on = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.designNumber + ":" + self.caption + ":" + self.supplier.name
I want to be able to have the image (cloudinary image) have a public id made up of the other params – like supplier.user.id and designNumber.
How do we do this?
Thanks.
In the latest version of the Python library you can inherit from CloudinaryField and determine the public_id (and the other upload parameter) from the model’s attributes e.g.: