Skip to content
Advertisement

Django multiple params link

I have this urls.py

path('calendar/<dt:date>/', views.CertainDay.as_view(), name="classrooms"),
path('calendar/<dt:date>/<int:classroom>/', views.ScheduleList.as_view(), name="schedule"),

first path with one args works good with reverse func in some file

how i can do this -> from .../calendar/2020-01-01 to .../calendar/2020-01-01/100 in template without using context and 2 args like url " " date arg2

something like <a href = "{% url 'schedule' *** %}> tries reverse full path with two args

Advertisement

Answer

If you are on URL www.website.com/calendar/2020-01-01/ and you want to go on www.website.com/calendar/2020-01-01/100/, you can have a relative link like this :

<a href="100/">Go to 100</a>

No need to use the template function {% url 'schedule' *** %} but this is not the cleaner solution since it is harder to debug.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement