db.models.fields.files.FieldFile.delete()

FieldFile.delete(save=True) [source]

Deletes the file associated with this instance and clears all attributes on the field. Note: This method will close the file if it happens to be open when delete() is called.

The optional save argument controls whether or not the model instance is saved after the file associated with this field has been deleted. Defaults to True.

Note that when a model is deleted, related files are not deleted. If you need to cleanup orphaned files, you’ll need to handle it yourself (for instance, with a custom management command that can be run manually or scheduled to run periodically via e.g. cron).

doc_Django
2016-10-09 18:35:32
Comments
Leave a Comment

Please login to continue.