Fix crash on Python 3.x and Django >= 1.5