Skip to content

Instantly share code, notes, and snippets.

@dpetukhov
dpetukhov / rupluralize.py
Last active September 7, 2023 14:39 — forked from xfenix/rupluralize.py
Russian pluralize django template tag
@register.filter(is_safe = False)
@stringfilter
def pluralize(value, forms):
"""
Подбирает окончание существительному после числа
{{someval|pluralize:"товар,товара,товаров"}}
"""
try:
one, two, many = forms.split(u',')
value = str(value)[-2:] # 314 -> 14