I am trying to create a dashboard with multiple customers rendered in the template, and a link to their individual profile. I was wondering if there is a way to pass in the url name and object pk id using django url in my template.
This is my code so far and I am getting a NoReverseMatch error.
urlpatterns = [
path('', views.index, name='home'),
path('dashboard/', views.dashboard, name='dashboard'),
path('about/', views.about, name='about'),
path('product/', views.product, name='product'),
path('customer/<int:pk>', views.customer, name='customer'),
]
<th><a href="{% url 'customer' %}">{{ customer.first_name }} {{ customer.last_name }}</a></th>
I understand that this is wrong but I cannot find the right way to do it. I am relatively new to django programming.
To pass keyword arguments to the url tag you pass arg=value
to the tag
{% url 'customer' pk=customer.pk %}