To add more detail:
The db version of the file won't be removed until the save method is
complete.
def save(self):
if self.id:
#The photo currently exists
m = MyModel.objects.get(pk=self.id)
if m.photo == self.photo:
#They are the same photo
else:
On Wed, 2008-07-09 at 17:02 +0200, KONTRA, Gergely wrote:
> > Could you override the save method and remove the file from the
> > filesystem prior to saving?
>
> That's what I'm attempting to.
> BUT:
> the question is: how can I figure out the database-saved value of the photo
>
> class
> Could you override the save method and remove the file from the
> filesystem prior to saving?
That's what I'm attempting to.
BUT:
the question is: how can I figure out the database-saved value of the photo
class MyModel(models.Model):
photo = ImageField(upload_to='temp')
def
Could you override the save method and remove the file from the
filesystem prior to saving?
e.g.
class MyModel(models.Model):
...
def save(self):
if self.id: # is a record in the database
# file system unlink call to self.path
super(MyModel, self).save()
Hi all!
Is it possible to access a model object's saved field values?
Purpose:
I have an ImageField, and if that field changes, I would like to
remove the old file from the filesystem. Now the only way to figure it
out is with a new query, but I suspect this hits the database again,
and seems a
5 matches
Mail list logo