[Answered ]-Remove trailing data from django timesince β€” template equivalent

2πŸ‘

βœ…

  1. Instead of template tag, use the timesince template filter. Like this:

    {{ datetime_obj|timesince:comparison_date }}
    

    Note, that comparison_date is optional.

  2. You can also use the naturaltime template filter of the humanize built-in lib. Like this:

    {{ datetime_obj|naturaltime }}
    

    If you choose the latter, don’t forget to add django.contrib.humanize to your INSTALLED_APPS setting and also put {% load humanize %} at the top of your template where you want to use naturaltime.

πŸ‘€nik_m

Leave a comment