2
-
Instead of template tag, use the
timesince
template filter. Like this:{{ datetime_obj|timesince:comparison_date }}
Note, that
comparison_date
is optional. -
You can also use the
naturaltime
template filter of thehumanize
built-in lib. Like this:{{ datetime_obj|naturaltime }}
If you choose the latter, donβt forget to add
django.contrib.humanize
to yourINSTALLED_APPS
setting and also put{% load humanize %}
at the top of your template where you want to usenaturaltime
.
Source:stackexchange.com