Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#3668 closed (duplicate)

URL tag should accept variable, a quoted literal

Reported by: yary h <not.com@…> Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: Keywords: URL tag
Cc: not.com@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm building up menus in django, and wanted a construct like this:
[[[
{% for item in menu %}
<a href="{% url item.view%}">{{item.label}}</a>
]]]
but that doesn't work, because there's no view "item.view"

That looks like a shortcoming/inconsistancy with the syntax of the URL tag. With most tags, an unquoted item gets looked up, and a quoted item is used as-is. Here, there's no way to look up the first argument to URL.

Suggested solution: require quotes for a literal (eg [{% url 'myapp.views.summarize_widgets' %}], and allow view names to be passed with the usual django syntax (eg [{% url item.some_view %}])

Change History (3)

comment:1 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

+1 from me.

comment:2 by Chris Beaven, 17 years ago

Resolution: duplicate
Status: newclosed

Dupe of #3796 (has more discussion)

comment:3 by yary h <not.com@…>, 17 years ago

Typo- this is a duplicate of #3769 (not 3796)

Note: See TracTickets for help on using tickets.
Back to Top