Comments (4)
Field file actually has delete
method, so you should be able to do this: model_instance.file_field.delete()
before deleting the whole model instance. (https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.fields.files.FieldFile.delete) Also, you should be able to do this: storageInstance.delete(model_instance.file_field.name)
.
You should never do sth like cloudinary.uploader.destroy(custommodel.image.public_id,invalidate=True)
, thats why you use storage from this package which does those low level things for you :). See https://github.com/klis87/django-cloudinary-storage/blob/master/cloudinary_storage/storage.py#L73
from django-cloudinary-storage.
That is what I was looking for!
I did the following
storage_instace.delete(name=model_instance.file.name)
model_instance.delete()
and it works great. Thanks a lot
from django-cloudinary-storage.
This is just how Django works for media files, it works the same for all storages, this is by design. If you dont like it, you can use Django signals or you can delete given file in overwritten delete model method, pls see Django docs for more info
from django-cloudinary-storage.
I understand. Is there a way to at least get the public_id
from the image and delete it doing something like
cloudinary.uploader.destroy(custommodel.image.public_id,invalidate=True)
from django-cloudinary-storage.
Related Issues (20)
- Setting for prefix HOT 3
- Implement upload options HOT 1
- File size too large -- but it isn't HOT 7
- How to get the full path HOT 5
- Add ability to manipualate option upload in settings.py HOT 1
- Django-utils.six dropped in Django 3.x HOT 9
- Unable to load large videos HOT 3
- Cannot find valid magic files. HOT 8
- Switch to Poetry with better dependency pinning
- issue with exists for raw files HOT 3
- Issue with uploading Django CKEditor images to cloudinary HOT 7
- This backend doesn't support absolute paths HOT 3
- This backend doesn't support absolute paths. HOT 2
- Unsupported video format or file HOT 3
- Can I set uppload option to private? HOT 5
- Static files don't work HOT 4
- How to apply cloudinary transformations outside of templates
- expected str, bytes or os.PathLike object, not NoneType HOT 1
- Error during management command: deleteredundantstatic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-cloudinary-storage.