Fix errors when used with Django 1.6