python - Display tweets on a page in Django using Tweepy -


i'm new django , python. i'm trying create django app display on page streaming of tweets account filtered ash tag (for moment hardcoded).

that s view.py

 tweepy.streaming import streamlistener  tweepy import oauthhandler  tweepy import stream  django.http import httpresponse   consumer_key="xxxxx"  consumer_secret="xxxxx"   access_token="xxxxxx"  access_token_secret="xxxxx"  class stdoutlistener(streamlistener):  def on_data(self, data):     print data     return true  def on_error(self, status):     print status  if __name__ == '__main__':      l = stdoutlistener()      auth = oauthhandler(consumer_key, consumer_secret)      auth.set_access_token(access_token, access_token_secret)  stream = stream(auth, l) stream.filter(track=['bt'])    def index(request):   return httpresponse("try") 

i have consumer_key, consumer_secret, acess_token , acess_token_secret edited. in urls.py have

 django.conf.urls import patterns, url  showtweets import views   urlpatterns = patterns('',      url(r'^$', views.index, name='index')  ) 

and ok if go index printing out "try". d print out stdoutlistener class thats 1 printing tweets, i'm sure working because terminal go in directory running

 python urls.py 

it s displaying tweets streaming on terminal. how display streaming on index page?

as @ testing / practicing stage, should use internal django web server can accessed by:

python manage.py runserver 

this start server on port 8000 can access @ http://127.0.0.1:8000. if site isn't on local machine add ip address yu want server run on:

python manage.py runserver 192.168.1.1 

i'm sorry if sounds cheeky, have gone through django tutorial @ https://docs.djangoproject.com/en/1.5/? 1 of first things mentioned in tutorial, if haven't gone through benefit enormously doing so.

also don't need first line in view (from django.db import models). i'd tell why, docs explain better could.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -