A Twisted Mind

Twisted + Django: It won't burn down your house.

It’s actually really easy to make these two things work together. Since ~8.2.0 Twisted has had a WSGI container runnable from the command line. So here is how you run Django on a supported version of Twisted.web.

  1. easy_install Twisted
  2. easy_install Django
  3. Profit!
  4. django-admin.py startproject foo
  5. Create a myapp.py with the following code:

    from django.core.handlers.wsgi import WSGIHandler

    application = WSGIHandler()
  6. export DJANGO_SETTINGS_MODULE=foo.settings
  7. twistd -no web --wsgi=myapp.application
And there you have it. There are probably a few compatibility problems but this mostly seems to work just fine. I’ll be working with some Django weenies to figure out what, if anything is broken.

So look, this is really AWESOME.

Updated (3/30/2009 4:09pm): Twisted tickets #3585, #3721 are problems on Twisted 8.2.0 but are fixed or should be fixed in Twisted trunk soon.

Updated (3/30/2009 6:34pm): Both of the above tickets are done.