Saving a message from tweepy to django model in a good way

I was wondering if anyone could point me in the right direction. I am trying to get twitter data and save it to the DB (using Django ORM / models).

My first approach was to create a model with all the relevant tweet information (Status) like this:

class Tweet(models.Model):
    """
    A tweet (Status) with all the respective metadata
    """
     id = models.BigIntegerField()
     lang = models.CharField(max_length=10)
     retweet_count = models.PositiveIntegerField()
     text = models.CharField(max_lenght=150)
     source = ....
     ....

And then fetch as:

#Almost pseudocode
from monitoring.models import Tweet
status = api.get_status('xxxx') # A simple tweet status with tweepy
newtweet = Tweet(id=status.id, screen_name = status.screen_name, followers_count = status.followers_count)
newtweet.save()

I think I could make it better and easier with a tweepy factory model , but I can't go in the right direction on my own ... any suggest? Any example / link / article would be great.

+4
source share

All Articles