Opened 16 years ago
Closed 16 years ago
#7803 closed (wontfix)
url template tag doesn't pass arguments to view
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | url templatetag | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
about <% url foo bar %> template tag.
when 'url' tag reverse url, arguments can't be sended properly in case below.
aggument that there is in views but not in url is CAN NOT SENDED from url template tag.
(examples)
<views.py>
def ticket(request, next=None):
context = {"next": next}
return render_to_response("ticket.html", context)
<ticket.html>
next={{ next }}
CASE 1:
RESULT is VALID case.
<urls.py>
url(r'ticket/$', 'my.test.views.ticket', {'next': 100}, name='test_ticket')
<caller.html>
<a href="{% url my.test.views.ticket %}">next ticket</a>
or <a href="{% url test_ticket %}">next ticket</a>
<result of ticket.html>
next=100
CASE 2:
RESULT is INVALID case.
<urls.py>
url(r'ticket/$', 'my.test.views.ticket', name='test_ticket')
<caller.html>
<a href="{% url my.test.views.ticket next=100 %}">next ticket</a>
or <a href="{% url test_ticket next=100 %}">next ticket</a>
<result of ticket.html>
next=None
CASE 3:
RESULT is VALID case. But, 'next' in url is dummy.
<urls.py>
url(r'ticket/(?P<next>.*)/$', 'my.test.views.ticket', name='test_ticket')
<caller.html>
<a href="{% url my.test.views.ticket next=100 %}">next ticket</a>
or <a href="{% url test_ticket next=100 %}">next ticket</a>
<result of ticket.html>
next=100
Change History (2)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Keywords: | templatetag added |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Summary: | Peter → url template tag doesn't pass arguments to view |
Marking WON'T FIX because the url template tag is only there to return a url. If you look at the mark up of case 3 the html is
<a href="/ticket/100/">
There is no way to pass python context into a HTML request. The url tag should not be expected to accomplish the case 2 action.
It is same thing that django.contrib.auth.views.logout
in template, 'next_page' value can not send to view.