django url - link problem
i have an application, and in my urls.py i have something like that:
urlpatterns = patterns('',
url(r'^profile_view/(?P<id>\d+)/$',
profile_vie开发者_运维技巧w,
name='profile_view'),)
meaning that the profile_view function has id as a parameter. Now, i want to call that function from my template, using a link like Reply
The problem is that i don't know how to use the above url as a link, meaning how can i 'pass the id parameter to a link'? thank you
Assuming this is closely linked to your other questions :o) ...
In your 'post' template, you'll want a link to your 'reply' view probably using the url tag. You should have the id of the current post in that template already passed in from the profile view? Something like:
<a href="{% url save_reply post_id %}">Reply</a>
edit:
In your template you should have an object available via your view that holds all of the ids to your blog posts. Then you would simply loop through those to display links for each
{% for entry in blog_list %}
<a href="yoururl.com/profile_view/{{ entry.id }}">{{ entry.name }}</a>
{% endfor %}
精彩评论