Add a "remove file" field for Image- or FileFields

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    the_file = models.FileField(
        upload_to="file/path",
        blank=True)
    remove_the_file = models.BooleanField()

    def save(self):
        if self.remove_the_file:
            self.the_file = ""
            self.remove_the_file = False
        super(ModelName, self).save()

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.