Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing an id in Django url

Tags:

django

I want to pass userid from django url to my view

Here is what I have written in Django template

<a href ={% url 'user_details' x.id  %} class='btn btn-primary' style="float: right;" >Know More</a></div>

To handle this url I have written Url like

url(r'^User/(\d{userid})/$', 'search.views.user_detail',name='user_details'),     

But I am getting an error i.e

NoReverseMatch at /search/

Reverse for ''user_details'' with arguments '(2L,)' and keyword arguments '{}' not found.

Please help me out What might I am doing wrong here .

like image 270
masterofdestiny Avatar asked Mar 25 '13 05:03

masterofdestiny


1 Answers

No quote ''

<a href ={% url user_details x.id  %} class='btn btn-primary' style="float: right;" >
    Know More
</a>

Another your url

url(r'^User/(?P<userid>\d+)/$', 'search.views.user_detail', name='user_details'), 
like image 168
catherine Avatar answered Oct 12 '22 12:10

catherine