[Fixed]-Passing an id in Django url

17👍

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'), 

11👍

Be carefull, after Django 1.5, use must use quotes. I came across this solution and tried it, got an error. I’m using Django 1.6 and you need the quotes:

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

hope it helps.

Leave a comment