2

I am trying to pass multiple url parameters from a django templated to be used by a view function. Below are my codes :

A snippet from the template from where the parameters will be passed onto :

<a href="{% url 'coordinator_assign_project_recommendations' group_id=row.group client_id=row.client  project_id=row.project_id %}" class="btn btn-primary">Assign</a>

The view function :

def assign_recommended_project(request, group_id, client_id, project_id):
    group = StudentGroup.objects.get(id=group_id)
    group.client = client_id
    group.project = project_id
    group.save()
    project = Project.objects.get(id=project_id)
    project.is_assigned = True
    project.save()
    return redirect("coordinator_view_groups")

The url of the view function :

 path(
        "coordinator/assign_recommended_project/<str:group_id/str:client_id/str:project_id",
        assign_recommended_project,
        name="coordinator_assign_project_recommendations",
    ),

This is the error that is shown :

error

Can someone please help me solve this. Thanks.

2 Answers 2

1

You need to open and close the angle brackets (<…>) for each parameter, so:

path(
    'coordinator/assign_recommended_project/<str:group_id>/<str:client_id>/<str:project_id>/',
    assign_recommended_project,
    name='coordinator_assign_project_recommendations',
),
Sign up to request clarification or add additional context in comments.

Comments

0
path(
        "coordinator/assign_recommended_project/<str:group_id>/<str:client_id>/<str:project_id>",
        assign_recommended_project,
        name="coordinator_assign_project_recommendations",
    )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.