Created
August 26, 2016 15:16
-
-
Save reverie/b97f432c647ec874d23a00877d6224a8 to your computer and use it in GitHub Desktop.
Django naturaltime with only one time denomination, no comma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks great, but this work only for ENGLISH language, do you have an idea for a multilingual website?