def cast_datetime_filter(value):
    """Cast a datetime filter value.

    :param value: string representation of a value that needs to be casted to
        a `datetime` object.

    """
    if isinstance(value, str):
        dtime = parse_datetime(value)

    elif isinstance(value, datetime):
        dtime = value
    else:
        raise ValueError('Received value of type {0}'.format(type(value)))

    return dtime.isoformat()
Cast a datetime filter value.

    :param value: string representation of a value that needs to be casted to
        a `datetime` object.