Re: accessing a model ojbect's saved fields

2008-07-09 Thread davenaff
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:

Re: accessing a model ojbect's saved fields

2008-07-09 Thread Malcolm Tredinnick
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

Re: accessing a model ojbect's saved fields

2008-07-09 Thread KONTRA, Gergely
> 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

Re: accessing a model ojbect's saved fields

2008-07-09 Thread Rob Hudson
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()

accessing a model ojbect's saved fields

2008-07-09 Thread pihentagy
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