def validate_image(value):
"""
Validates if the image which is uploading is exactly image, because file can be renamed.
Raises an error if validation not passed.
:param str value: The file object.
"""
if not imghdr.what(value):
raise ValidationError('Tried to upload not an image!')
# ----------------------------------------------------------------------------------------------------------------------
评论列表
文章目录