def validate_ext(value, valid):
    """ Validate a file field value for allowed extensions
    :param value: the field file value to validate extension
    :param valid: the allowed extensions to validate against
    :return: None
    """
    ext = os.path.splitext(value.name)[1]  # [0] returns path filename
    if ext not in valid:
        raise ValidationError("Unsupported file extension.")
dataset/ETHPy150Open Wtower/django-ninecms/ninecms/utils/media.py/validate_ext/original