Ticket #8912: filefield_commit_8975.diff
File filefield_commit_8975.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/files.py
71 71 72 72 def save(self, name, content, save=True): 73 73 name = self.field.generate_filename(self.instance, name) 74 self._name = self.storage.save(name, content) 74 if save: 75 self._name = self.storage.save(name, content) 76 else: 77 self._name = '%s (unsaved)' % name 78 75 79 setattr(self.instance, self.field.name, self.name) 76 80 77 81 # Update the filesize cache … … 89 93 self.close() 90 94 del self._file 91 95 92 self.storage.delete(self.name) 96 if save: 97 self.storage.delete(self.name) 93 98 94 self._name = None95 setattr(self.instance, self.field.name, self.name)99 self._name = None 100 setattr(self.instance, self.field.name, self.name) 96 101 97 # Delete the filesize cache98 if hasattr(self, '_size'):99 del self._size102 # Delete the filesize cache 103 if hasattr(self, '_size'): 104 del self._size 100 105 101 if save:102 106 self.instance.save() 103 107 delete.alters_data = True 104 108