Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#14389 closed (fixed)

Future url replacement

Reported by: Sean Brant Owned by: nobody
Component: Template system Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


As previously discussed in #7917 context variables inside {% url %} do not work. Ticket #7917 purposed fiddling with the current {% url %} trying to make it support quoted/un-quoted view names as well as view names defined in the context. This ticket was closed by core as invalid, however this feature is still needed imho. In this thread[1] Malcolm suggested creating a new tag that depreciated the use of unquoted "string based" view names. I raised the issue recently[2] on django-dev and Russ recommend creating a new tag living in a future_url module that once loaded {% load future_url %} it would replace the old url tag. This allows us the ability to switch over the tags in a couple of releases giving developers time to upgrade code.

So the upgrade path would look something like this.

1.3: adds the new behavior only if you {% load future_url %} also if you are using the old url we throw a PendingDeprecationWarning
1.4: upgrades the warning to DeprecationWarning
1.5: replaces the old style url with the new on in template_tags/ the url tag defined in emplate_tags/ would now throw a DeprecationWarning
1.6: remove template_tags/

Since we are moving to a new tag in stages I also figured we can officially remove support for comma separated url arguments in favor of the new style.

My patch does all of above with some docs and tests. This is my first time writing docs so I suspect those will need some tweaking.



Attachments (2)

future_url-1.diff (7.4 KB) - added by Sean Brant 8 years ago.
t14389-rc1.diff (32.4 KB) - added by Russell Keith-Magee 8 years ago.
RC1 of a patch fixing url and ssi template tags

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by Sean Brant

Attachment: future_url-1.diff added

comment:1 Changed 8 years ago by Alex Gaynor

There's gotta be a way to do this with less copy-paste. Perhaps the "normal" URLNode can defer resolving the URL name to a method and this can just override this to actually consult the context.

comment:2 in reply to:  1 Changed 8 years ago by Sean Brant

I thought about this, i think its a good idea. URLNode is easy we can define a resolve_view method on the class. What do we do about the url function? Should we not use parser.compile_filter in the url function and just pass the string to URLNode and have resolve_view do Variable(self.view_name).resolve(context)?

comment:3 Changed 8 years ago by Daniel F Moisset

Owner: changed from nobody to Daniel F Moisset


comment:4 Changed 8 years ago by Daniel F Moisset

Owner: changed from Daniel F Moisset to nobody
Triage Stage: UnreviewedAccepted

There was further discussion in this thread:

Russ preapproved this as long as the "load future_url" syntax was used («Feel free to accept the new ticket for the 1.3 milestone. »)

Changed 8 years ago by Russell Keith-Magee

Attachment: t14389-rc1.diff added

RC1 of a patch fixing url and ssi template tags

comment:5 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [14643]) Fixed #14389, #9666 -- Started the migration path to make the first argument to url and ssi template tags syntactically consistent with other tags. Thanks to Sean Brant for the draft patch.

comment:11 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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