Tweepy Not Displaying

24 views
Skip to first unread message

coded kid

unread,
Mar 28, 2012, 6:56:12 PM3/28/12
to Django users
Hi guys, I want to display user’s timeline in my django app but it’s
not working. It only display a white blank page! I’m using Tweepy.
Below are my codes:

Views.py

import tweepy

def tweetstream(request):
consumer_key="XXXX"
consumer_secret="XXX"
access_token="XXX"
access_token_secret="XXXX"
auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api=tweepy.API(auth)
status=api.user_timeline()
for status in status:
if status:
status.__getstate__()
return render_to_response('tweet.html',
context_instance=RequestContext(request))

Template:
{% extends "base.html" %}

{% block content %}

{% for status in status %}
{% if status %}
{{ status.author.screen_name}} {{status.text}}
{{status.source}}

{% endif %}
{% endfor %}


{% endblock %}

What I’m I missing? How can I make it return user’s timeline?

creecode

unread,
Mar 28, 2012, 8:22:33 PM3/28/12
to django...@googlegroups.com
Hello coded kid,

On Wednesday, March 28, 2012 3:56:12 PM UTC-7, coded kid wrote:
 
Template:
 
 {% for status in status %}

That bit looks like it might cause trouble.  You are assigning status to status.  Normally you'd want something like...

{% for status in statuses %}

or

{% for status in status_list %}

or

{% item in status %}

Use whatever variable names you want as long as you're not clobbering variables that are needed while looping.

Toodle-loooooooooo................
creecode

Tom Evans

unread,
Mar 29, 2012, 4:46:44 AM3/29/12
to django...@googlegroups.com
On Wed, Mar 28, 2012 at 11:56 PM, coded kid <duffle...@gmail.com> wrote:
> Hi guys, I want to display user’s timeline in my django app but it’s
> not working. It only display a white blank page! I’m using Tweepy.
> Below are my codes:
>
> Views.py
>
> import tweepy
>
> def tweetstream(request):
>    consumer_key="XXXX"
>    consumer_secret="XXX"
>    access_token="XXX"
>    access_token_secret="XXXX"
>    auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
>    auth.set_access_token(access_token, access_token_secret)
>    api=tweepy.API(auth)
>    status=api.user_timeline()
>    for status in status:
>        if status:
>            status.__getstate__()
>            return render_to_response('tweet.html',
> context_instance=RequestContext(request))

I'm not sure this is the best place to ask how to use tweepy*. I know
about django, not tweepy, so I can't tell you if you are using the
tweepy API correctly.

You're returning inside a loop. This means that the first time status
is true, you will exit the loop. I'm not sure that is intentional.

>
> Template:
> {% extends "base.html" %}
>
>  {% block content %}
>
>  {% for status in status %}

'for status in status' is probably going to work, but why be so
confusing? Also, what is this 'status' variable? You are passing no
variables named status to the template - in fact, you're not passing
anything.

Cheers

Tom

* This is one of my pet peeves. Just because you are using django +
(random bit of software), it doesn't mean you well get good support
for (random bit of software) on the django mailing lists.

Reply all
Reply to author
Forward
0 new messages