I am working on a django- Google app engine project. A user inserts some value and the datetime field is auto filled using google app engine DateTimeProperty(auto_now_add=True) property. Now, I have to display on the template the difference of this time and the current time when the user is viewing the result.
For e.g. if the inserted time was 5:00 and the user is viewing the post at 6:00, the result should be 1 hour. Is there any builtin filter available with the Django templates to perform the same? I tried timesince as:
{{ topic.creation_date| timesince: now }}
where creation_date is a datetime field. But its not working.
Please suggest.
Thanks in advance.
Do you have a variable called "now" in your context? If not, that will fail.
However, you don't actually need one, because if you call the timesince filter without an argument, it will use the current time. So just do:
{{ topic.creation_date|timesince }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With