Code

Opened 7 years ago

Closed 7 years ago

#4774 closed (invalid)

feature request: {% url %} should resolve pattern names

Reported by: canburak@… Owned by: adrian
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

url template tag should work exactly like reverse(). It should also resolve the url pattern name.

Attachments (0)

Change History (4)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #3769

comment:2 Changed 7 years ago by mtredinnick

  • Resolution duplicate deleted
  • Status changed from closed to reopened

I don't see how this is a dupe of anything. More precisely, I don't really understand what it is saying. Which features of reverse() are missing and needed in the url template tag?

Reopening for the time being until more information is available.

comment:3 Changed 7 years ago by anonymous

  • Cc reb@… removed

in urls.conf you can define names for url patterns like:

(r'^accounts/profile/$', 'baklava.reiloy.shared_page.profile', {}, "profile")

reverse("profile") resolves to /accounts/profile/

{% url "profile" %} resolves to empty.

comment:4 Changed 7 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from reopened to closed

Leave out the quotes. The url tag is a slightly odd duck, in that literal strings are not parsed (because it only handles literal strings). You use a pattern name just like a view function name.

If you look in tests/regressiontests/templates/tests.py, you can see a few examples of pattern names being used.

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.