'Validates that the input can be converted to a time. Returns a Python
datetime.time object.'

def to_python(self, value):

    if (value in validators.EMPTY_VALUES):
        return None
    if isinstance(value, datetime.time):
        return value
    for format in (self.input_formats or formats.get_format('TIME_INPUT_FORMATS')):
        try:
            return datetime.time(*time.strptime(value, format)[3:6])
        except ValueError:
            continue
    raise ValidationError(self.error_messages['invalid'])
