'How I can connect each name in list using id concept (python)

I created a list of users page and user profile page and I want when click on any name in the list it should show that user profile page.

in .html

<table class="table table-striped " id="table1"> 
<thead> 
<tr class="feed-bg text-white "> 
<th>Employee Name</th>
 <th>Employee Email</th>
 </tr>
 </thead> 
<tbody> 
{% for i in data_list %} 
<tr>
  <td>{{ forloop.counter }}</td>
  <td><a href="/user/edit_profile/"> {{i.employee_name}} </a></td>
  <td>{{i.employee_email}}</td>
 </tr> 
{% endfor %}
 </tbody> 
</table>

view.py of user list page

def user_list(request): 
data_list = [] 
get_user_details = CustomUser.objects.all() 
for i in get_user_details: 
data_dict = {} 
data_dict['employee_name'] = i.username 
data_dict['email'] = i.email 
data_list.append(data_dict) 
 return render(request, 'user_list.html', {'data_list': data_list})

urls

 path('user_list/', views.user_list, name='user_list'),
 path('profile/', views.profile, name='profile'), 

profile page

<div class="row r-bg mt-3"> 
<div class="row g-3">
{% for data in get_user_details %}
<div class="col-md-3"> 
<label for="username" class="form-label">Full Name *</label>
<input type="text" class="form-control" name="username" id="username" value="{{data.username}}"> </div> 
<div class="col-md-3"> 
<label for="email" class="form-label">Email *</label> 
<input type="email" class="form-control" name="email" id="email" value="{{data.email}}">
</div> 
</div>
<div class="row mt-5"> 
<div class="col-md-8 mt-3">
<button type="button" class="btn btn-outline-primary">save</button>
</div> 


Solution 1:[1]

you must get profile_id in url.py like this:

path('profile/<int:profile_id>', views.profile, name='profile'), 

then call that in your template:

{% url profile 'profile' i.profile_id %}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohsen sami