right-tree/backend/right_tree/api/signals.py

13 lines
332 B
Python
Raw Normal View History

from shutil import rmtree
from django.db.models.signals import post_delete
from django.dispatch import receiver
from .models import Export
from .resource_generation_utils import storage
@receiver(post_delete, sender=Export)
def delete_export(sender, instance, *args, **kwargs):
rmtree(storage.path(f"export_{instance.pk}"))