Compat fixes for Django 1.6

This is a subset of #928 that gets us closer to Django 1.6 without actually switching to it.