Thank you for the reply. When i add the [0] to tweet, the date conversion is only applied to the last tweet....
On 7 mrt, 23:24, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Mar 7, 9:57 pm, "het.oosten" <het.oos...@gmail.com> wrote: > > > > > I am almost done implementing tweets on my site using a tutorial which > > a found > > here:http://www.omh.cc/blog/2008/aug/4/adding-your-twitter-status-django-s... > > > The problem is that i want to modify the date output when i retrieve > > multiple tweets. The example above is written for retrieving only one > > most recent tweet from twitter. > > > The context_preprocessor i have now is (mostly taken from the site > > above): > > > import datetime > > import time > > from django.conf import settings > > from django.core.cache import cache > > import twitter > > > def latest_tweet( request ): > > tweet = cache.get( 'tweet' ) > > > if tweet: > > return {"tweet": tweet} > > > tweet = twitter.Api().GetUserTimeline( settings.TWITTER_USER, > > count=3 ) > > tweet.date = datetime.datetime(*(time.strptime( tweet.created_at, > > "%a %b %d %H:%M:%S +0000 %Y" )[0:6])) > > cache.set( 'tweet', tweet, settings.TWITTER_TIMEOUT ) > > > return {"tweet": tweet} > > > This results in the following error: > > AttributeError: 'list' object has no attribute 'created_at' > > > The twitter api let me call a human readable date in the template > > using relative_created_at. Unfortunately the output is in English. > > > Any idea how i get an easy readable date? > > > The output is now: > > Fri Oct 30 10:18:53 +0000 2009 > > > Or: > > about 6 days ago > > When i use relative_created_at > > I don't know the Twitter API, but you're calling GetUserTimeline with > a count of 3, which presumably returns a list of 3 items. The list > itself doesn't have a 'created_at' attribute, hence the error. Perhaps > if you did: > > tweet = twitter.Api().GetUserTimeline(settings.TWITTER_USER, > count=3) [0] > > you would have better luck. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.