Django 1.11.7 Python 3.6.5
我尝试在删除模型时实现以下代码来删除文件。 但是没有调用post_delete。
@receiver(post_delete, sender=HogeFileModel, dispatch_uid=uuid.uuid4())
@receiver(post_delete, sender=FugaFileModel, dispatch_uid=uuid.uuid4())
def auto_delete_file_on_delete_part_file(sender, instance, using, **kwargs):
print('Called post_delete')
if instance.file:
if os.path.isfile(instance.file.path):
os.remove(instance.file.path)
如何解决?