Fix compatibility with custom user model in django 1.5 and above