def custom_timesince(value):
now = datetime.datetime.now()
# can add some error checking if you want
diff = now - value
if diff < timedelta(days=1):
return "recently" # or w/e you wanted with the hours
# remove trailing information from timesince
return timesince(value).split(", ")[0]
您可以创建自己的模板标记,并使用它将
timesince
的输出修改为您喜欢的任何内容。下面是一个简单的例子:可能有帮助:docs on using such custom tags
相关问题 更多 >
编程相关推荐