def delete_test_image(image_field):
"""
Deletes test image generated as well as thumbnails if created.
The recommended way of using this helper function is as follows:
delete_test_image(object_1.image_property)
:param image_field: The image field on an object.
:return: None.
"""
warnings.warn(DeprecationWarning(
"delete_test_image() is deprecated in favour of the "
"get_sample_image() context manager."), stacklevel=2)
# ensure all thumbs are deleted
for filename in glob.glob(
os.path.join(
settings.MEDIA_ROOT, 'thumbs', image_field.name.split('/')[-1]
) + '*'
):
os.unlink(filename)
# delete the saved file
image_field.delete()
评论列表
文章目录