def update_zipfile(sender, instance, **kwargs):
""" Delete zip file on pre_save. This is needed in case of updation of
zip file, where the older file should be deleted from the location"""
if instance.pk:
details = SponsorProjectDetailsSubFields.objects.get(pk=instance.pk)
if details.zip_file and details.zip_file.url != instance.zip_file.url:
storage, path = details.zip_file.storage, details.zip_file.path
storage.delete(path)
评论列表
文章目录