Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3668 closed (duplicate)

URL tag should accept variable, a quoted literal

Reported by: yary h <not.com@…> Owned by: adrian
Component: Template system Version: master
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: UI/UX:

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 %}?])

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

+1 from me.

comment:2 Changed 7 years ago by SmileyChris

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #3796 (has more discussion)

comment:3 Changed 7 years ago by yary h <not.com@…>

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.