Update (2007/04/13) - DjangoKit got better since, you know. But everyone keeps linking here for some reason…
DjangoKit is a framework that will (eventually) allow me to package just
about any Django application as a stand-alone MacOS .app. I’ve been noodling
with the concept for a while now, but I was finally motivated to do something
after I saw Slingshot and started reading about Apollo and
related technologies. I’ve tried using Ruby and Rails, and tried again as a result of seeing Slingshot, but I really don’t enjoy it. I’m a Python
person, and most of my personal projects (including jerakeen.org itself)
are written in it, so it seemed like it would be easier to re-implement the interesting parts of Slingshot as a PyObjC app than re-write everything I care about in Rails. Also, I’m weird.
Like slingshot, the built .app gets a local (sqlite) database that works offline, but I’m not thinking at all about sync with a remote server. It’s an orthogonal problem that can be solved later. I also don’t care about non-mac users right now. Lots of the hard bits of the code are in the bundling system, and should be convertible into py2exe rules, so I won’t rule out doing the same thing for Windows, but this is a personal project, and I’m a mac weenie this month, so if you want it, you can do it. Likewise linux.
It’s early yet - I’ve only really spent a couple of days hacking on it - but I have a downloadable demo available - it’s an utterly trivial application, but demonstrates Django with a model, a generic view and a template, as well as the admin site that Django provides magically. The demo app source code is avaliable if you want to see how trivial the app is, or you can get the entire thing as source - both from my subversion repository. I’m not promising the thing will build for you, though. You’ll need PyObjC, Django and pysqlite2 installed, and they mustn’t be installed as eggs. Running setup.py the first time will generate a local
database.sqlite with the tables for the app model. I haven’t solved the schema upgrade problem yet. :-)
The code is almost entirely nasty hacks, so beware, but it should be possible to clean it up and produce something more elegant. Eventually I want to be able to turn just about any Django application into a Mac application by writing a small config file describing it, but right now you should be able to ship your application by:
- editing theproject/urls.py and adding a dispatcher for it
add the package name of your project to the
- make sure your app is in your python library path
delete the local
database.sqlite(so the models are regenerated)
python setup.py py2app
If you need media files shipped, try putting them in
./media, and they’ll be bundled with everything else, but this isn’t so well tested. The first time you run the app it’ll copy the database into
~/Application Support/DjangoKit/appname so you’ll also need to clean that folder out if you change the model.