def prepare_lookup_value(key, value):
    """
    Return a lookup value prepared to be used in queryset filtering.
    """
    if key.endswith('__in'):
        value = value.split(',')
    elif key.endswith('__isnull'):
        value = value.lower() not in ('', 'false', '0')
    return value
