AndresVargas
Hi!, my nickName is zodman, im a Computer science Engineering.
love the FLOSS and FreeSoftware. Python ninja and php coder.
On left my love Aisha and me.
Interest links
seen more
Django with twitter status
Im add a simple tag on django with my twitter last status. It's cached because twitter haves problems with alots of request...... so here the code
Create a templatetags on your model/ dir
# filename twitter.py from django.template import Library import urllib import simplejson register = Library() @register.simple_tag def twitter_status( username ): url = "http://twitter.com/statuses/user_timeline/%s.json?count=1" % username file = urllib.urlopen(url) json_responce = file.read() twit = simplejson.loads(json_responce) return "%s" % twit[0]["text"]
Add it to my index.html page on templates
{%load cache %} {% cache 18000 twitter %} {% load twitter %} <div class="twitter"> <img src="/static/images/twitter.gif"> @zodman: {% twitter_status "zodman" %} </div> {% endcache %}
Yeap my firts time of used cache on templates. That is very similar of the code of my friend blacknash, he Implement it on blog of h1pp1e
Comment (1)
@zodman: prox chingadazo facebook app para dar chingadazos a tus compaƱeros!