Skip to main content

model_ngettext

Return the appropriate verbose_name or verbose_name_plural value for obj depending on the count n.

obj may be a Model instance, Model subclass, or QuerySet instance. If obj is a QuerySet instance, n is optional and the length of the QuerySet is used.

def model_ngettext(
obj: Union[Model, Type[Model], QuerySet],
n: int = None
) - > string

Return the appropriate verbose_name or verbose_name_plural value for obj depending on the count n.

Parameters

NameTypeDescription
objUnion[Model, Type[Model], QuerySet]The Django Model instance, Model class, or QuerySet from which to retrieve verbose name metadata.
nint = NoneThe count used to determine whether to return the singular or plural form; if omitted and obj is a QuerySet, the queryset count is used.

Returns

TypeDescription
stringThe singular or plural verbose name of the model based on the provided or calculated count.