-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
The README says
"Note that when a field referencing a file is cleared, the corresponding file in the database and on the file system will not be automatically deleted"
https://django-db-file-storage.readthedocs.io/en/master/#models contains an example of how to add automatic deletion for their solution:
from db_file_storage.model_utils import delete_file, delete_file_if_needed
from django.db import models
class Console(models.Model):
name = models.CharField(max_length=100, unique=True)
picture = models.ImageField(..., blank=True, null=True)
def save(self, *args, **kwargs):
delete_file_if_needed(self, 'picture')
super(Console, self).save(*args, **kwargs)
def delete(self, *args, **kwargs):
super(Console, self).delete(*args, **kwargs)
delete_file(self, 'picture')
Can something like that be added here?
Metadata
Metadata
Assignees
Labels
No labels