I think it could work like this, and it 'asks for forgiveness, rather than permission':

    try:
        username = request.user.get_username()
    catch(AttributeError):
        username = request.user.username