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?
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?
You can import the functions in the model:
from django.contrib.humanize.templatetags.humanize import naturalday
natural_day = naturalday(value)
© 2022 - 2024 — McMap. All rights reserved.
import
ing them directly? What happened? – Aubert