def METHOD_NAME(request, pk):
    queryset = UserProfile.objects.prefetch_related('roles', 'roles__body')
    try:
        UUID(pk, version=4)
        profile = get_object_or_404(queryset, pk=pk)
    except ValueError:
        profile = get_object_or_404(queryset, ldap_id=pk)
    if profile.profile_pic is None:
        profile.profile_pic = settings.USER_AVATAR_URL
    rendered = render_to_string('user-details.html', {
        'profile': profile,
        'achievements': profile.achievements.prefetch_related('body', 'event').filter(hidden=False),
        'settings': settings
    })
    return HttpResponse(rendered)