Package: django-carson
django-carson makes it easy to store and display tweets from a set of
users or tweets about a given topic.For an idea of how django-carson can be used, take a look atTweetNevada.The basic idea is you’ll have a set of Twitter accounts you want to
follow (e.g., Nevada lawmakers) and a set of common hashtags and/or
keywords (e.g.,#nvleg) used by the community to engage in a
collective conversation about a given topic.  When combined on the
same page, you get a very interesting and dynamic conversation taking
place.Getting StartedInstall django-carson:$ mkvirtualenv --no-site-packages example_website
$ pip install django-carsonAddcarsonto yourINSTALLED_APPSCreate the database tables withsyncdb(ormigrate carsonif you
useSouth)To access theTwitter Streaming API, you must first create the
appropriate tokens.First,create a new application.  Then, click “Create my access
token.”Add the following values tosettings.py“Consumer key” →CONSUMER_KEY“Consumer secret” →CONSUMER_SECRET“Access token” →TOKEN_KEY“Access token secret” →TOKEN_SECRETVia theadmin interface, add your accounts and hashtags/keywords.Note:You’re not required to add both accounts and
hashtags/keywords.  If you want, you could design a site that only
stored hashtag mentions or only tweets sent by your given set of
users.If you added any accounts, you must either run./manage.py lookup_twitter_idsor use the “Lookup Twitter IDs” admin action
before the next step will work.  If you only added hashtags or
keywords, you don’t need to do this.Finally, run:$ ./manage.py get_tweetsThis will open a connection to the Twitter Streaming API and
immediately after one of your accounts posts a tweet or a
tweet is created mentioning one of your tags, that tweet will be
stored.Usagedjango-carson is only a bridge between Django and the Twitter
Streaming API.  It is the web developer’s job to wire up the views and
templates needed to actually display the data.The main entry point for any developer usingcarsonis likely to
becarson.models.Tweet.  This model holds all tweets stored withget_tweets.Eachcarson.models.Tweetobject has four attributes:accountA ForeignKey pointing to thecarson.models.Accountthat
created the tweet, if applicable.  Will beNoneif the tweet
didn’t come from an account listed incarson.models.Account.timestampThe UTC timestamp of the tweet.status_idThe unique status id for each tweet.  This is also in data[‘id’],
but this allows an index to be created for it.dataStores the completeJSONobject associated with the tweet.  You
can see what all is included in this attributehere.Attached tocarson.models.Tweetare three managers:objectsReturns aQuerySetof all tweetstrustedReturns only the tweets associated with acarson.models.Account.  In other words,Tweet.account != None.untrustedReturns only the tweets not associated with acarson.models.Account.  In other words,Tweet.account == None.A simple index view exists incarson.views.indexwhich grabs the
20 most recent trusted and untrusted tweets and renderscarson/index.html(with the context variablestrustedanduntrusted).  Might be useful if your website isn’t too complex.If you seem to be having problems accessing the Twitter API, you can
setHTTP_DEBUGtoTrueinsettings.py.  By default it isFalse.Changelog0.2 (October 5th, 2011)Use SSL for Streaming and REST APIsDocument and test some utility methodsUserequestsfor
REST API calls0.1 (August 9th, 2011)Initial release