django url patterns with 2 parameters

Viewed 42389

This is simple and obvious but I can't get it right:

I have the following view function declared in urls.py

 (r'^v1/(\d+)$', r'custom1.views.v1'),

originally I was passing a single parameter to the view function v1. I want to modify it to pass 2 parameters. How do I declare the entry in urls.py to take two parameters?

4 Answers

in django 2.x and 3.x:

url:

    path("courses/<slug:param1>/<slug:param2>", views.view_funct, name="double_slug")

template:

    <a href="{% url 'double_slug' param1 param2 %}">Click {{param2}}!</a>
Related