Skip to main content

prepare_lookup_value

Return a lookup value prepared to be used in queryset filtering.

def prepare_lookup_value(
key: string,
value: any,
separator: string =
) - > any

Return a lookup value prepared to be used in queryset filtering.

Parameters

NameTypeDescription
keystringThe queryset filter key (e.g., 'id__in' or 'active__isnull') used to determine the necessary transformation logic.
valueanyThe raw input value to be transformed, which can be a string, a list of values, or a boolean-like string.
separatorstring = ,The character used to split the input string into a list when the key specifies an '__in' lookup.

Returns

TypeDescription
anyThe processed value or list of values formatted for Django-style queryset filtering, such as a boolean for null checks or a list for membership tests.