Friday, March 30, 2012

Tweepy Image and Link display

Hi guys, how can I get users twitter handle with link and display
their image in my django app. What I mean is this, I want the users
username should be clickable (so that when I click on it it will
direct me to the user profile), and display the user profile image by
their update. I hope you get my point?

Below are mu codes:

Views:

def tweetstream(request):
consumer_key=""
consumer_secret=""
access_token=""
access_token_secret=""
auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api=tweepy.API(auth)
statuses=api.friends_timeline(count=30)
for status in statuses:
status.__getstate__()
return render_to_response('tweets.html',{'statuses':
statuses}, context_instance=RequestContext(request))

Templates:

{% extends "base.html" %}


{% block content %}


{% for status in statuses %}
<p> {{ status.author.screen_name}} :</p>
<p> {{ status.text|safe }} </p>
<p> {{ status.created_at }} Via: {{status.source}} </p>
{{ status.profile_image_url }}

{% endfor %}

{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment