Requires {% load humanize %}
Add {% load humanize %} near the top of any template that
uses |naturalday. Without it Django does not
know the name and raises TemplateSyntaxError.
{% load humanize %} only works when
"django.contrib.humanize" is in your
INSTALLED_APPS — the load fails before the
library is ever reached.
Replaces a date with today, yesterday, or tomorrow when it is one of those, and formats it normally otherwise.
Template
{% load humanize %}
<p>Published {{ post.published|naturalday }}</p>
Result
<p>Published yesterday</p>
It compares dates, not moments, so anything at all on yesterday's calendar date reads as “yesterday”. When you want “3 hours ago”, reach for naturaltime instead.
