diff --git a/api/models/indiening.py b/api/models/indiening.py index 3d1dc624..ca72f2b6 100644 --- a/api/models/indiening.py +++ b/api/models/indiening.py @@ -77,13 +77,14 @@ def save(self, *args, **kwargs): if "temp" in self.bestand.name: old_file = self.bestand - new_path = self.bestand.name.replace( + old_file_name = old_file.name + new_path = old_file.name.replace( "temp", f"indiening_{self.indiening_id}" ) default_storage.save(new_path, ContentFile(old_file.read())) self.bestand.name = new_path super(Indiening, self).save(*args, **kwargs) - old_file.storage.delete(old_file.name) + default_storage.delete(old_file_name) else: super(Indiening, self).save(*args, **kwargs)