I figured it out finally.

For anybody who is interested. I have this setup for showing multiple
tweets:

settings.py:
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS = TEMPLATE_CONTEXT_PROCESSORS + (
    "wieskamp.verkoop.context_processors.latest_tweet",
)

TWITTER_USER = "username"
TWITTER_TIMEOUT = 3600

This context_processor:
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 )
        for s in tweet:
                s.date =
datetime.datetime(*(time.strptime( s.created_at, "%a %b %d %H:%M:%S
+0000 %Y" )[0:6]))
        cache.set( 'tweet', tweet, settings.TWITTER_TIMEOUT )

        return {"tweet": tweet}

And this in my template:
        {% if tweet %}
                {% for x in tweet %}
                        {{ x.text|urlize}} <br />
                        {{ x.date|date:"d/m/Y" }}<br /><br />
                {% endfor %}
        {% endif %}

Thanks for the help and hints :-)

-- 
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.

Reply via email to