Есть адресная строка:
localhost/patient/id/1/consultation и
localhost/patient/id/1/consultation/2
В файле urls.py:
urlpatterns = [
url(r'^$', views.index, name='patient'),
url(r'id/(?P<id_patient>[0-9]+)/$', views.patient, name='patient'),
url(r'id/(?P<id_patient>[0-9]+)/consultation/(?P<id_consultation>[0-9]+)', views.consultation, name='patient_consultation'),
]
Во views.py
def consultation(request, id_patient, id_consultation):
patient = Patient.objects.get(pk=id_patient)
return render(request, 'patient/id/consultation/index.html', locals())
Как сделать последний параметр(параметр консультации) не обязательным?