Link specific to user django -


i have website list of users looking service displayed 1 signed provide service. have following code:

      {% customer in customers %}                     <tr>                          <td style = "text-align:center">{{ customer.user.first_name|title }} {{ customer.user.last_name|title }}</td>                         <td style = "text-align:center">{{ customer.user.profile.address|title }}</td>                         <td style = "text-align:center"><a href="{% url 'claim' %}">claim</a></td>                     </tr>                 {% endfor %} 

for claim link, how can pass information specific user linked page(say claim.html)?

you can add info query parameter:

<td style = "text-align:center"><a href="{% url 'claim' user_id=customer.user.id%}">claim</a></td> 

then, can use parameter in view.

your url should this:

 url(r'^claim/(?p<user_id>[0-9]+)/$', views.claimview.as_view(), name='claim') 

then, in view can this:

class claimview(view):     def get(self, request, user_id, *args, **kwargs):         user = user.objects.get(id=user_id)         # whatever want  

hope helps!


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -