Cleanups in preparation for Django 1.6

all these bits should still work on 1.4, but fix test failures under 1.6.