Home:ALL Converter>Saving post from tweepy to django model in a good way

Saving post from tweepy to django model in a good way

Ask Time:2014-07-25T18:20:47         Author:chaim

Json Formatter

I was wondering if any could point me in the right direction. I'm trying to fetch twitter data and save it to a DB (with Django ORM / models).

My first approach was to create a model with all relevant information of a tweet (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 fetching like:

#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)

I guess I could do better and easy with tweepy models factory but I can't go in the right direction by my own...any suggest? Any example/link/article would be great.

Author:chaim,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24953494/saving-post-from-tweepy-to-django-model-in-a-good-way