2👍
Assuming that your model looks like this:
from cloudinary.models import CloudinaryField
class CustomModel(models.Model):
image = CloudinaryField('image',blank=True,null=True)
user = models.OneToOneField(User,blank=True, null=True, unique=True, verbose_name=_('User'))
And in the view:
import cloudinary.uploader
import cloudinary
import CustomModel.models
custommodel= CustomModel.objects.get(user=request.user)
cloudinary.uploader.destroy(custommodel.image.public_id,invalidate=True)
You probably can’t delete the photo because you didn’t pass public_id to Cloudinary. public_id is an attribute in the CloudinaryField.
0👍
Try to extract the public_id
of the resource from a CloudinaryResource
object using the public_id
property.
- [Answered ]-Django-allauth Facebook error
- [Answered ]-How to verify if django settings are applied correctly?
- [Answered ]-Page not found 404 with Django
Source:stackexchange.com