def image_format ( value ) : if value . image . format . upper ( ) not in constants . ALLOWED_IMAGE_FORMATS : raise ValidationError ( MESSAGE_INVALID_IMAGE_FORMAT )
how to validate an impput python
Confirms that the uploaded image is of supported format .
def image_format(value):
    """
    Confirms that the uploaded image is of supported format.

    Args:
        value (File): The file with an `image` property containing the image

    Raises:
        django.forms.ValidationError

    """

    if value.image.format.upper() not in constants.ALLOWED_IMAGE_FORMATS:
        raise ValidationError(MESSAGE_INVALID_IMAGE_FORMAT)