mirror of
https://github.com/RobbieHan/sandboxMP.git
synced 2026-02-03 02:43:14 +08:00
13 lines
357 B
Python
13 lines
357 B
Python
import os
|
|
|
|
from django.dispatch import receiver
|
|
from django.db.models.signals import post_delete
|
|
|
|
from .models import DeviceFile
|
|
|
|
|
|
@receiver(post_delete, sender=DeviceFile)
|
|
def auto_delete_file(sender, instance, **kwargs):
|
|
if instance.file_content:
|
|
if os.path.isfile(instance.file_content.path):
|
|
os.remove(instance.file_content.path) |