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
is a good idea~
#
This is simple and nice. I prefer to not add an extra database column when it's not needed, though. You can just create a custom ModelForm for your model, with the following:
Use that form in your ModelAdmin, and there's no need to change the database.
Thanks for the idea!
#