On Wednesday 01 July 2009 09:01:58 David Zhou wrote:
> On Tue, Jun 30, 2009 at 11:21 PM, Kenneth Gonsalves
>
> <law...@thenilgiris.com> wrote:
> > has anyone succeeded in marrying django to twitter - that is broadcasting
> > updates in the django db to twitter? I did see one post on the subject in
> > the archives, but there was no information as to whether the operation
> > was successful.
>
> I haven't tried it, but it shouldn't be hard.  Subscribe to the
> relevant signals for whatever you want to track, and use a Python
> Twitter library to post to the Twitter account.
>
> I've used Mike's module at: http://mike.verdone.ca/twitter/ previously
> to great success.   To post something an account with that module:
>
> import twitter
> t = twitter.api.Twitter('username', 'password')
> t.statuses.update(status="This is the tweet.")

works - here is the code:

def tweetit(sender,**kwargs):
    """
        extract relevant info and tweet it
        """
    if kwargs['created']:
        t = twitter.Api(settings.TWITTER_USER, settings.TWITTER_PASSWORD)
        t.PostUpdate("%s has registered as a delegate" 
%(kwargs['instance'].username))
    
post_save.connect(tweetit, sender=Delegate)

-- 
regards
kg
http://lawgon.livejournal.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to