@library.global_function
def display_name(user):
    """Return a display name if set, else the username."""
    try:  # Also mostly for tests.
        profile = Profile.objects.get(user_id=user.id)
    except (Profile.DoesNotExist, __HOLE__):
        return user.username
    return profile.display_name if profile else user.username
dataset/ETHPy150Open mozilla/kitsune/kitsune/users/templatetags/jinja_helpers.py/display_name