from django.apps import AppConfig class ProjectsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'projects' def ready(self): from django.db.models.signals import post_delete from .models import CardAttachment def remove_stored_file(sender, instance, **kwargs): if instance.file: instance.file.delete(save=False) post_delete.connect(remove_stored_file, sender=CardAttachment, weak=False, dispatch_uid='projects.remove_attachment_file')