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}"))