Comments (8)
Hi!
You don't need to use signals in this case.
from django-cleanup.
What I did is simply call os.remove(kwargs['file'])
in my callback.
from django-cleanup.
The purpose of signals is to interact with third-party API's. If you don't need to interact with third parties then you don't need to use the signal interface. This library will handle the deletion of files for you (using django's File object API), you don't need to call os.remove
yourself.
from django-cleanup.
@vinnyrose Hi, that is what I want but I can see that the test app explicitly deleted the file in the callback passed to the signal.
Can you then please tell me how I should use the signal if my model looks like the example above?
from django-cleanup.
For the model above, you don't need to use signals.
The code you are referencing in the test app is not explicitly deleting the file, it is calling an API function (delete
) provided by sorl_thumbnail which deletes thumbnail files (related to but separate from the original file) and clears caches used internal in the sorl_thumbnail app.
The actual deletion of the original file happens here.
For most developers, including yourself, you simple pip install django-cleanup
then add django_cleanup
to INSTALLED_APPS
and it will work as specified.
from django-cleanup.
@vinnyrose Oh that is it πThank you!
from django-cleanup.
Hi!
You don't need to use signals in this case.
Maybe you can mention this in README, so that people will know for native app, it doesn't need to add any extra code to use this module.
Also, thanks for the super easy-to-use module! π
from django-cleanup.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from django-cleanup.
Related Issues (20)
- `storage` option for `FileField` doesn't change for tests HOT 4
- add compatibility with django-versatileimagefield HOT 3
- Feature/Management command (`cleanup_files`) HOT 1
- Remote storage? HOT 3
- Deletes unwanted files HOT 7
- Make a Django 3.0 release HOT 3
- No CHANGELOG HOT 1
- Have option to use django-cleanup explicitly on models HOT 6
- In production django-cleanup with aws s3 is not working HOT 5
- Deletes Files shared between instances HOT 8
- Support integration with django-reversion HOT 5
- PermissionError: There was an exception deleting the file because it is being used by another process HOT 4
- Check uniqueness before delete? HOT 4
- Files not deleted on database rollbacks HOT 1
- Migrate to new CI platform HOT 2
- Exclude a particular file/files? HOT 2
- Cleanup empty directories HOT 3
- FileField ID in pre-delete HOT 1
- When copying Model-Instances as per django documentation, adjusting either deletes the File for the other HOT 4
- Not working with Django 4.1+ HOT 1
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-cleanup.