I think the problem is that urlconf provides a url => view mapping.
Really though, for creating the links, we need the reverse mapping.  We
usually know the view we want to display, but don't know it's URL.

For example, you have a bulletin board app:

urls.py:
urlpatterns = patterns(''
    '^comments/(\d+)/', 'sample.bboard.view_comment')
.....

def view_comment(id):
    comment = Comment.objects.get(id)
    responses = comment.responses.all()
    render_to_response('template', {'comment': comment, 'responses':
responses})


Currently, you could define the template like this:
template.html:
.....
{% for response in responses %}
<a href="{{ response.get_absolute_url }}">{{ response.title }}</a>
{% endfor %}

But, really, all you want is a tag like this:
{% for response in responses %}
<a href="{% view_function_url 'sample.bboard.view_comment' response.id
%}">{{ response.title}}</a>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to