[Answered ]-Django: NoReverseMatch at /patient/1/

1👍

change this

<a href="{% url 'register_visit' %}{{patients.id}}" class="btn btn-primary">Nouvelle Chirurgie</a>

to

<a href="{% url 'register_visit' patients.id %}" class="btn btn-primary">Nouvelle Chirurgie</a>

i hope that patients is not a queryset if it is you should iterate over it using forloop for this code above to work.
urls.py:

urlpatterns = [
    path('', views.index, name='index'),
    path('register_patient/', views.registerPatient,name='register_patient'),
    path('register_booking/', views.registerBooking,name='register_booking'),
    path('register_visit/<int:id>/', views.registerVisit,name='register_visit'),
    path('<int:id>/', views.detail_patient,name='detail_patient'),
]

in detail_patient i added a name=’detail_patient’.

<a href="{% url 'detail_patient' field.id %}" class="btn btn-warning">Details</a>

field.id is just an example you should replace with the instance you want.

Leave a comment