Opened 18 years ago
Closed 18 years ago
#5408 closed (duplicate)
Url tag first argument should be able to be a context variable
| Reported by: | 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)
Change History (7)
comment:1 by , 18 years ago
| Triage Stage: | Unreviewed → Design decision needed |
|---|
comment:2 by , 18 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 , 18 years ago
| Attachment: | 5408.patch added |
|---|
changed url to accept vars and quoted strings for the first argument (view path)
comment:3 by , 18 years ago
| Component: | Uncategorized → Template 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 , 18 years ago
| Owner: | changed from to |
|---|
comment:5 by , 18 years ago
| Status: | new → assigned |
|---|
comment:6 by , 18 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | assigned → closed |
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).
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.