Opened 17 years ago

Closed 17 years ago

#5408 closed (duplicate)

Url tag first argument should be able to be a context variable

Reported by: Øyvind Saltvik <oyvind@…> Owned by: Philippe Raoult
Component: Template system Version: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If the first view/name argument to the url tag used a context var it would be easier to reuse in inculded templates

I have two views that takes the same kwargs i could do

{% with "someview" as myview %}
{% url myview slug=object.slug %}
{% endwith %}

Instead of writing the same code twice.

So:

{% url "someview" slug=object.slug %}

{% url myview slug=object.slug %}

Would mean the same thing

Attachments (1)

5408.patch (6.3 KB ) - added by Philippe Raoult 17 years ago.
changed url to accept vars and quoted strings for the first argument (view path)

Download all attachments as: .zip

Change History (7)

comment:1 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

Maybe it's useful, but it breaks the templates for anyone who has used {% url %} thusfar. If that's acceptable, then we should move this to accepted.

comment:2 by Philippe Raoult, 17 years ago

It would be very useful, though a clean implementation would require having a separate url_var tag that does what you ask.

by Philippe Raoult, 17 years ago

Attachment: 5408.patch added

changed url to accept vars and quoted strings for the first argument (view path)

comment:3 by Philippe Raoult, 17 years ago

Component: UncategorizedTemplate system
Has patch: set
Needs tests: set

as per discussion with devs on #django-sprint, my patch changes the url tag behavior (backward incompatible). Regression tests seem ok.

comment:4 by Philippe Raoult, 17 years ago

Owner: changed from nobody to Philippe Raoult

comment:5 by Philippe Raoult, 17 years ago

Status: newassigned

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: duplicate
Status: assignedclosed

This seems to be identical to what #3769 requested, so marking as a dupe (it's a massive backwards incompatible change, so would need django-dev sign-off before we implemented it).

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