I fetched tweets from twitter. In the template tweets loop, I tried to print how long ago this tweet was created. So this is what I tried:
<li class="twitter-feed-block-content">
{{ tweet.text }}
<span class="when">
{{ tweet.created_at|timesince }}
</span>
</li>
{{tweet.text}} is printing correctly. However, when I add the next line {{ tweet.created_at|timesince }} I get the following error:
Exception Value: 'unicode' object has no attribute 'year' Exception
Location: REMOVED_BY_ME/lib/python2.7/site-packages/django/utils/timesince.py
in timesince, line 29 Python
Executable: REMOVED_BY_ME/bin/python
Python Version: 2.7.2
The tweet.created_at is a string. Is this the reason? if so, how I can convert it so that it works seamless with timesince filter?
Thanks in advance
Ok, this is how I’ve solved the question. As I told, I wanted to create custom filter as a last resort only.
So, i’ve created a filter named
strtotimesince. i’m putting it here so that it helps if someone faces similar problem.