def make_request(request, permission, permittee, target_obj_or_class,
                 redirect_to=None):
    
    if permittee != request.user:
        raise PermissionDenied
    
    assert(isinstance(permittee, User))
    try:
        done_url = request.session["breadcrumbs"][-1][1]
    except IndexError:
        done_url = reverse("home")
    # get all the roles that have this permission
    roles = ProjectRole.objects.filter_for_permission(
        permission.name, target_obj_or_class)
   
    if not roles:
       return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH+"/no_permission.html",
        extra_context={
            "cancel_url": done_url,
            "target": target_obj_or_class,
        }
        )
 
    # for each role get the users that can delegate it
    roles_to_users = {}
    for r in roles:
        givers = get_users_for_role(r, can_delegate=True)
        roles_to_users[r.id] = givers

    if request.method == "POST":
        req = ProjectRoleRequest(requester=request.user)
        form = SelectRoleForm(
            roles, roles_to_users, request.POST, instance=req)
        if form.is_valid():
            req = form.save()
            DatedMessage.objects.post_message_to_user(
                "Request for '%s' role in project '%s' sent to user '%s'"
                    % (req.requested_role.name,
                       req.requested_role.project,
                       req.giver.username),
                user=request.user,
                msg_type=DatedMessage.TYPE_SUCCESS)
            return HttpResponseRedirect(done_url)
    else:
        form = SelectRoleForm(
            roles, roles_to_users)

    return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH+"/make_request.html",
        extra_context={
            "cancel_url": done_url,
            "form": form,
            "target": target_obj_or_class,
        }
    )
When a permission is missing allow user to request a role.
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/roles/views.py/make_request