How to use django.contrib.humanize in a model

1.5k Views Asked by At

I would like to use the django.contrib.humanize outside of a template, actually inside a model to humanize some dates in some text messages.

Is it possible? How can I do this?

1

There are 1 best solutions below

0
André Luiz On

You can import the functions in the model:

from django.contrib.humanize.templatetags.humanize import naturalday
natural_day = naturalday(value)