Django 1.5 fix, PEP fixes