def _get_username(user):
    if hasattr(user, 'get_username'):  # custom user, django 1.5+
        return user.get_username()
    elif hasattr(user, 'username'):    # standard User
        return user.username
    else:                              # assume user is just an username
        return user
Return user's username. ``user`` can be standard Django User
dataset/ETHPy150Open django-webtest/django-webtest/django_webtest/__init__.py/_get_username