Reputation: 176
everyone. I decide to use Cloudinary for storing images. This is my model field with image:
avatar = models.ImageField(upload_to='avatar/', default='avatar/default.png', blank=True)
All works fine for me, but I have one little issue. When I uploaded the image from admin panel, cloudinary upload it to my cloudinary folder 'avatar' with some modified name, for example: 'july2022_kda4th' or 'july2022_aidkdk' But when I uploaded this image from admin panel of another database (production), cloudinary upload the image with another name. So, I have two similar images in cloudinary. It's not convenient. How can I fix it?
Upvotes: 0
Views: 338
Reputation: 111
By default, if you don't supply a public_id in the upload API call, a random string is assigned to the asset. You can read more here: https://cloudinary.com/documentation/upload_images#public_id.
It sounds like you want to use the asset filename as the public_id so what you can do is:
use_filename=true
and unique_filename=false
as described in this linkOR if above is not working you can
Use filename or externally defined Public ID:
optionUnique filename:
upload_preset
in your upload callUpvotes: 1