0

I am using the Django template filter tag timesince. it displays well time Greater than one minute. But when is less than one minute it showing 0 minutes ago i want it to be in seconds

here is my code

<p>{{ article.article_published_date| timesince | upto :',' }} ago</p>

I need ouput as 20seconds ago is there any way to display
The template tag am using now is

from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()

@register.filter
@stringfilter
def upto(value, delimiter=None):
    return (value.split(delimiter)[0])
upto.is_safe = True


any help will be appreciated Thanks in advance

Pavan kumar
  • 478
  • 3
  • 16

1 Answers1

1

You'll have to write your own template tag as timesince docs state

Minutes is the smallest unit used, and “0 minutes” will be returned for any date that is in the future relative to the comparison point.

Source of timesince

iklinac
  • 14,944
  • 4
  • 28
  • 30
  • I am new to django. why don't you example template tag code to display return seconds – Pavan kumar Jun 24 '20 at 08:49
  • i have one template tag excisting i will provide that in question – Pavan kumar Jun 24 '20 at 08:50
  • I have answered your question with clear documentation that timesince does not have seconds also gave you approach where you should look next . You should write it, it is your job/hobby you misrepresent what this site is for ,check out this link ( https://idownvotedbecau.se/noattempt/ ). – iklinac Jun 24 '20 at 08:56