Skip to main content

NullBooleanSelect

A Select Widget intended to be used with NullBooleanField.

Constructor

Signature

def NullBooleanSelect(
attrs: dict = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneOptional dictionary of HTML attributes to be set on the rendered widget.

Signature

def NullBooleanSelect(
attrs: dict = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneA dictionary containing HTML attributes to be rendered on the select element.

Methods


format_value()

@classmethod
def format_value(
value: any
) - > string

Converts the internal Python value into a string representation suitable for the HTML option tags.

Parameters

NameTypeDescription
valueanyThe Python boolean, string, or legacy integer-string value to be mapped to a widget choice.

Returns

TypeDescription
stringA string value of 'true', 'false', or 'unknown' used to set the selected state in the HTML template.

value_from_datadict()

@classmethod
def value_from_datadict(
data: dict,
files: dict,
name: string
) - > boolean | null

Extracts and normalizes the value from the submitted form data into a Pythonic boolean or None.

Parameters

NameTypeDescription
datadictThe dictionary of submitted form data, typically request.POST or request.GET.
filesdictThe dictionary of uploaded file data.
namestringThe name of the form field used as the key to look up the value in the data dictionary.

Returns

TypeDescription
`booleannull`