Django and the iPhone

[UPDATE]: I’ve begun developing an application using Django and the iPhone.

Yesterday morning after seeing a Flickr post on Jacob Kaplan-Moss’ tumble log, I decided to try my own hand at installing django on my iphone.

Here is the result: Django inspecting my iPhone call database

How did I do this? Well first, somehow get SSH installed on your iPhone. Either using jailbreak or use BlueDonkey’s excellent iPhoneOpener script, which is the route I choose.

Next, you’ll need to use your newly opened ssh channel to your phone to scp over NerveGas’ python installation for the iPhone.

Next, check out Django trunk to your local machine and scp that over to your /var/root folder. I copied it into a directory called django.

Next I added /var/root/django to my pythonpath, and created a new django application in /var/root called iphone, and updated my pythonpath accordingly.

Next, I updated my django settings.py file to point to /var/root/Library/CallHistory/call_history.db, and ran manage.py inspectdb to extract a model for the call database.

You’ll need to add primary_key=True to the id field in the model it generates, and also add the following to the generated model:

class Admin:
  list_display = ('__str__', 'duration')

def __str__(self):
  return self.address

Once that step is complete, add django.contrib.admin to your INSTALLED_APPS tuple, uncomment the link to admin/ in urls.py and then run manage.py syncdb.

It will add django’s auth, core and such to your call_history.db (Not for the weak of heart, not sure if this effects future calls. All I know is that it doesn’t seem to, but YMMV.)

Next, you can fire up manage.py runserver and visit your call database by going to http://127.0.0.1:8000/admin/ in MobileSafari.


About this entry