Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to post to Twitter from a django app?

Tags:

django

twitter

What I want to do is pretty straightforward. I have a site powered by django. I want to have the site automatically post to twitter any time a new object is created and saved in the database. What is the absolute best way to do this?

like image 877
Apreche Avatar asked Jul 10 '09 02:07

Apreche


2 Answers

One way is the following:

First, handle the post_save signal from Django. Note that post_save passes your handler a boolean parameter created to let you know whether it's a new object that was saved.

  • http://docs.djangoproject.com/en/dev/ref/signals/

Then, call the python-twitter library's PostUpdate function within your handler to notify on twitter:

  • http://code.google.com/p/python-twitter/
like image 93
ars Avatar answered Nov 16 '22 01:11

ars


Try using the function post_to_twitter() from this: http://www.djangosnippets.org/snippets/1339/

like image 32
sreenath Avatar answered Nov 16 '22 02:11

sreenath