backports from django 1.6 (these will be needed later, just trying to minimize the diff file between this branch and userena branch)