Skip to content

Instantly share code, notes, and snippets.

@reverie
Created August 26, 2016 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reverie/b97f432c647ec874d23a00877d6224a8 to your computer and use it in GitHub Desktop.
Save reverie/b97f432c647ec874d23a00877d6224a8 to your computer and use it in GitHub Desktop.
Django naturaltime with only one time denomination, no comma
@register.filter
def short_naturaltime(value):
from django.contrib.humanize.templatetags.humanize import naturaltime
base = naturaltime(value)
if ',' not in base:
return base
return base.split(',', 1)[0] + ' ago'
@FlorianBouron
Copy link

Looks great, but this work only for ENGLISH language, do you have an idea for a multilingual website?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment