Django Tips #2 humanize.
Django comes with a set of template filters to add a “human touch” to your data. It is used to translate numbers and dates into a human readable format.
Personally, I use the template filter
naturaltime a lot. It looks good in the user interface and is very easy to implement. Basically what it is gonna do is translate
09 May 2016 20:54:31 into
29 seconds ago(considering when now is 20:54:00).
To install Django Humanize, add
django.contrib.humanize to your
Now in the template, load the template tags:
Using it is very straightforward, for example the
naturaltime template filter:
Following the available template filters:
Read more on the official Django Documentation.