Every time I make a model with a File or Image Field I create a
corresponding boolean field called clear_fileFieldName.  And then I
override the save action.  Checking to see if that clear_fileFieldName
is set to true.  If it is I, clear the FileField

Like this
class Property(models.Model):
    thumbnail = models.ImageField(upload_to='images/thumbnails',
blank=True)
    clear_thumbnail = models.BooleanField()
    def save(self):
        if self.clear_thumbnail:
            self.clear_thumbnail = False
            self.thumbnail = ''
        super(Property, self).save()

It's kind of a hack, but it works for now.

On Nov 16, 10:12 am, Marc Garcia <[EMAIL PROTECTED]> wrote:
> There are a couple of things about FileFields that I want to comment.
>
> First one is about how to delete content in a FileField. With a
> example:
>
> 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.
>
> Second problem that I have. With an example as well.
>
> In last application I want my users to upload its own data, so I
> create a page with a form generated with form_for_model for previous
> model.
>
> When displayed, for a user that already exists, and already has a
> picture, an empty <input type="file" ... /> is displayed for picture
> field. User can't see it's own picture with admin's link, and when
> saved, old picture is dropped. I think that it should work like in
> admin (with delete checkbox).
>
> Please, comment me what you think about and if necessary I'll develop
> fixing patches.
>
> Thanks!
>   Marc
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to