I know I can use the humanize module to convert date/time to a friendlier format in the django templates. I was wondering if I can convert those things outside the templates. For example in a views.py
function or a models.py
class(meaning outside of a django template). Is there any other library that can do that?
Asked
Active
Viewed 8,962 times
33

Trect
- 2,759
- 2
- 30
- 35

averageman
- 893
- 3
- 12
- 19
1 Answers
78
Yes you can
Lets say you want to call naturalday
in views.py
you would do
from django.contrib.humanize.templatetags.humanize import naturalday
natural_day = naturalday(value)
You can refer to the source code here for the signature, and options

karthikr
- 97,368
- 26
- 197
- 188