django-tweet-saved 0.8.1

Tweet Django's saved objects

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
BSD License 
Elmar Athmer
ROOT \ Internet \ HTTP (WWW)
django-tweet-saved is a Django app that will create a tweet if a model has been saved. Useful to announce news, blogposts, etc.

How does it work?

 * notification via django service
 * shortens url with googl (via python-googl)
 * uses package twitter to tweet the notification
 * remember that an instance has been tweeted (via djangos contentype/generic foreign keys), so notifications are only sent once

How to use it

 1. Install, add tweet to your INSTALLED_APPS.
 2. get the oauth token/secret and add it to your

 ./ tweet_oauth
 Hi there! We're gonna get you all set up to use tweet_saved.

 In the web browser window that opens please choose to Allow
 access. Copy the PIN number that appears on the next page and paste or
 type it here:

 Please enter the PIN: 1234567
 Please add
 to your

 3. Register your model

 from tweet import tweeter

 class MyModel(models.model):


 4. if not present, add a method get_absolute_url to your model.
 5. recommended steps (but not required): Add a property twitter_message to your model to define the message to tweet. This message will automatically shrinked to fit into the 140 character limit.

 If this method is not defined, the object is simply converted to string.

 This is the twitter_message of my object, augmented with hashtags (using the tags from django-tagging):

 def twitter_message(self):
 reo = re.compile('(%s)' % '|'.join([ for x in self.tag_objects]), flags=re.IGNORECASE)
 return 'Blog: ' + re.sub(reo, '#\g< 1 >', self.headline)

 Add a method may_tweet returning a bool, if you want to delay the tweet, i.e. wait until the object is marked as public.


 def may_tweet(self):
 return self.published is not None and <

 6. If you want to keep track of the shortened urls, get a Google/Googl key, and add it to your

 GOOGL_KEY = 'xxxx'

Last updated on February 19th, 2011


#saved objects #tweet objects #Django #Twitter #tweet #objects

Add your review!