Django 1.4 support

Fixes #307.  Needs review.