Skip to main content

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

NameTypeDescription
valueanyThe raw data value to be formatted, such as a date, number, string, or boolean.
empty_value_displaystringThe fallback string to display if the provided value is considered empty (e.g., None or an empty string).
booleanboolean = FalseA flag indicating whether the value should be rendered as a boolean icon instead of a text string.

Returns

TypeDescription
stringThe formatted representation of the value, which may be a localized string, a comma-separated list, or an HTML icon for boolean types.