mardi 13 décembre 2016

how to trigger the clear checkbox in an ImageField in django

in my models I have a class:

class Location(models.Model):
     name = models.CharField(max_length=200)
     image_file = models.ImageField(upload_to=get_filename,null=True, blank=True)

This gives me an image field with an additional "clear" checkbox.

I was wondering how I could trigger this clear function from shell. After creating a location with an image I tried:

./manage.py shell 
from myapp.models import Location 
l = Location.objects.all()
l[0].image_file.save(clear=True)
l[0].image_file.clear=True

But none of them worked. Is there any way to manually trigger this clear checkbox?

It has nothing to do with the delete function, that much I was able to figure out.

Aucun commentaire:

Enregistrer un commentaire