display_for_value
Converts a given value into a localized, human-readable string representation for display, handling booleans, dates, numbers, and empty values according to Django's formatting rules.
def display_for_value(
value: any,
empty_value_display: string,
boolean: boolean = False
) - > string
Converts a raw Python value into a localized, human-readable string or icon suitable for display in the Django admin interface.
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The raw data value to be formatted, such as a date, number, string, or boolean. |
| empty_value_display | string | The fallback string to display if the provided value is considered empty (e.g., None or an empty string). |
| boolean | boolean = False | A flag indicating whether the value should be rendered as a boolean icon instead of a text string. |
Returns
| Type | Description |
|---|---|
string | The formatted representation of the value, which may be a localized string, a comma-separated list, or an HTML icon for boolean types. |