> I've a model:
>
> class Person(model.Model):
> name = models.CharField(maxlength=32)
> [...]
> picture = models.ImageField(upload_to='pictures', blank=True)
>
> Imagine that I've created a person record with a picture of anoother
> person, and I want to delete it (the picture). How can I do? I think
> that in admin it should be a checkbox for FileFields to remove
> content.
You van override the delete() method, with something like:
class Person(model.Model):
name = models.CharField(maxlength=32)
[...]
picture = models.ImageField(upload_to='pictures', blank=True)
def delete(self):
import os
from mysettings import MEDIA_ROOT
os.remove(MEDIA_ROOT+self_picture)
super(Person, self).delete()
... or something like that.
p.s. you might wanna put os.remove in a try...except statement, just
in case.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---