from django.utils import timesince, dateformat @register.filter def timetoggle(time, id): link = "<span id=\""+str(id) + "timesince\"> about <a href=\"#\" onmouseover=\"document.getElementById('"+str(id)+"timeactual').style.display=''; document.getElementById('"+str(id)+"timesince').style.display='none';return false;\">" link += timesince.timesince(time) link += " ago</a> </span><span id=\""+str(id)+"timeactual\" style='display:none'> at <a href=\"#\" onmouseout=\"document.getElementById('"+str(id)+"timeactual').style.display='none'; document.getElementById('"+str(id)+"timesince').style.display='';return false;\">" link += dateformat.DateFormat(time).format("g:ia o\\n l jS N Y") link += "</a></span>" return mark_safe(link)