I was working on a project and I needed to hook on some twitter API onto Django.
I researched quite a bit and came across Twython.
Twython is the the easiest Twitter client for Django in terms of :
- executing of common functions such as searching, retrieving public timeline results.
If you do not want to install using the official method described here, you can simply drop the files streaming.py, twitter_endpoints.py and twython.py ( found in the folder twython , right here ) into your django app.
Give it a try, it should work for you.
This is in response to the previous post: http://www.liangeugene.com/2010/08/going-social-giving-your-django-app-social-capabilities/ . Apparently, there was some bugs with the reqiured dependencies, so I am going to try out Django SocialAuth found at : http://uswaretech.com/blog/2009/08/django-socialauth-login-via-twitter-facebook-openid-yahoo-google/.
I am back with some things I have learned using South.
Here it goes:
There are many times where we want to use South on existing apps. In the previous post, I’ve only pointed to the exsiting tutorials found on South’s website at http://south.aeracode.org/docs/convertinganapp.html.
In case you want to know what the whole process looks like, here it is:
Firstly, assuming you have an existing project, for instance se. And within se you have an existing app called ajax. Here’s the original models.py:
Go to settings.py, and add ‘south’ in your installed apps section.
Next, you will be required to run the following command in your terminal:
You should see something like this:
Creating table south_migrationhistory
No fixtures found.
Not synced (use migrations):
(use ./manage.py migrate to migrate these)
Syncing…Creating table south_migrationhistoryNo fixtures found.
Synced: > django.contrib.auth > django.contrib.contenttypes > django.contrib.sessions > django.contrib.sites > django.contrib.admin > se.example > se.register > se.ajax > south
Not synced (use migrations): - (use ./manage.py migrate to migrate these)
After you received the above response, you will need to run the next command:
You will see a response where South is creating migrations directory and so on.
The response above is based on the assumption that your models defined in models.py is in sync as per what is found in you database.
Now, let us make a small change in your models.py: Change the original models.py as shown earlier in the post, by appending the following line to it:
And now for the final step, run the following command in your terminal:
You will see a response from South stating that “The field ‘Ajax.text’ does not have a default specified, yet is NOT NULL”. This simply means that you need to specify some kind of default values for the existing fields that originally do not have the field text. In my case, I typed in “this is default“.
Now once you are done, you might want to pop over to your database, which is phpmyadmin in my case, and you will see that the new field is now added to the Ajax model.
Ok that’s all for now.