I tried to override delete() method of Car model and it works when i delete
single object using admin site.
But it doesnt work with deleting many objects at once.
So i ended up with this:
def post_delete_image_deleting(sender, instance, **kwargs):
storage, path = instance.photo.storage, insta
Thanks! Both methods are useful.
четверг, 15 ноября 2012 г., 18:02:02 UTC+4 пользователь lingrlongr написал:
>
> I've use something like this:
>
> class Car(models.Model):
> #some fields
> photo = models.ImageField(upload_to='cars')
>
> def delete(self, *args, **kwargs):
> stor
I've use something like this:
class Car(models.Model):
#some fields
photo = models.ImageField(upload_to='cars')
def delete(self, *args, **kwargs):
storage, path = self.photo.storage, self.photo.path
super(Car, self).delete(*args, **kwargs)
storage.delete(path)
I think you need to do this with a signal, or on post_save
On Thu, Nov 15, 2012 at 12:48 AM, Sergey Seleznev wrote:
> Hi! I'm new to python and django(well, and web dev too).
> I'm using python 2.7 and django 1.4
> I went through the tutorial and then got issue with files managing.
> I have model
Hi! I'm new to python and django(well, and web dev too).
I'm using python 2.7 and django 1.4
I went through the tutorial and then got issue with files managing.
I have model like this:
class Car(models.Model):
#some fields
photo = models.ImageField(upload_to='cars')
and media url/root con
5 matches
Mail list logo