Opened 15 years ago

Closed 15 years ago

#11462 closed (worksforme)

{% url %} tag is not working with the 'AS' modifier and named URLs

Reported by: x13 Owned by: nobody
Component: Template system Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've included this lines into my urls.py

...
url(r'^coming-soon$', direct_to_template, {'template': 'soon.html'}, name='en-soon'),
url(r'^proximamente$', direct_to_template, {'template': 'soon.html'}, name='es-soon'),
...

Then, I tried to use them in my homepage.html with the {% url ... as ... %} tag:

...
{% url en-soon as url_soon %}
<a href="{{ url_soon }}">comming soon</a>
...

but it didn't work.

Next, I tried use {% url %} without the as modifier:

...
<a href="{% url en-soon %}">comming soon</a>
...

and it worked.

Change History (1)

comment:1 by Ramiro Morales, 15 years ago

Resolution: worksforme
Status: newclosed

What do you mean with it didn't work? I tested this with Django 1.0, 1.0.2 and trunk and it worked as expected (the alias variable evaluates to the correct URL for the link href). Reopen the ticket if you are willing to provide more details about your setup and exact failure.

PS: I used this template fragment:

<ul>
{% url en-soon as url_soon_en %}
{% if url_soon_en %}
<li><a href="{{ url_soon_en }}">English</a></li>
{% endif %}
{% url es-soon as url_soon_es %}
{% if url_soon_es %}
<li><a href="{{ url_soon_es }}">Spanish</a></li>
{% endif %}
</ul>
Note: See TracTickets for help on using tickets.
Back to Top