[Django]-Saving post from tweepy to django model in a good way

0👍

we used pickle and saved the twitter data in a variable(hard disk) if that helps you. Just use pickle in your model like this:

import pickle
filename = 'finalized_model.sav'
pickle.dump(LR_model, open(filename, 'wb'))
pickl={'vectorizer':tf_vector,'model':LR_model,'clean':clean()}
pickle.dump(pickl,open('models'+".p","wb"))

and then put this in your django apps.py:

path = os.path.join(settings.MODELS, 'models.p')
    with open(path, 'rb') as pickled:
        data = pickle.load(pickled)
    model = data['model']
    vectorizer = data['vectorizer']

given that you have declared your model in setting.py. then fetch twitter data use it in views.py

Leave a comment