Geeking Out

Using Capistrano to deploy Django web apps

These last few weeks I’ve been working on an outside project that is written in Django (thanks to the involvement of one of the two coders behind Polihood). When it came time to deploy this app to our dev server, we started looking at the Capistrano deployment tool. Unfortunately the documentation for Capistrano is lacking, but the tool itself is darn slick, so I gave it a go.

Capistrano was built as a deployment manager for Ruby on Rails applications, but it has been expanded with additional functionality, and seems to be slowly moving towards being a general-purpose tool. I’ve seen other tutorials written about using Capistrano to deploy web apps that aren’t Rails, but generally they consist of sticking a bunch of shell commands into a Capfile and letting it run, which doesn’t really seem to be the “Capistrano way.”

What I’ve done is use Capistrano’s built in Rails deploy functionality and have been writing overrides as I find that I need them. Right now the script only does a basic deploy or rollback, but eventually I’ll probably extend it to do other things as well.

Remarkably, very little needs to change in the standard deploy library to work with Django. Here is my Capfile as it currently stands.

4 replies on “Using Capistrano to deploy Django web apps”

  1. Sweet! I use Capistrano for deploying my Rails apps, and I’d heard but was skeptical that it can be used easily for deploying non-Rails apps. I’m glad to hear that it’s working out for you!

  2. Yeah, the script would need to be substantially expanded to deal with things like cold deploys, database migrations (which Django doesn’t really have a facility for), etc., but its a good start and easier than I anticipated. The code itself is well commented, which offsets the lack of decent documentation.

Comments are closed.