normalize_choices
Normalize choices values consistently for fields and widgets.
def normalize_choices(
value: Any,
depth: int = 0
) - > Union[list, Any]
Normalize choices values consistently for fields and widgets.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Any | The raw choice data to be normalized, which can be a mapping, iterable, callable, or Django Choices enumeration. |
| depth | int = 0 | The current recursion depth used to prevent infinite loops and control how nested structures are processed. |
Returns
| Type | Description |
|---|---|
Union[list, Any] | A list of 2-tuples representing the normalized choices, or the original value if it cannot be unpacked or is a lazy/string-like type. |