Opened 12 years ago

Closed 12 years ago

#18762 closed Uncategorized (fixed)

Problem with url in templates

Reported by: jendxb@… Owned by: Aymeric Augustin
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This:

<li><a href="{% url 'polls.views.detail' poll.id %}">{{ poll.question }}</a></li>

...does not work.

But this:

<li><a href="{% url polls.views.detail poll.id %}">{{ poll.question }}</a></li>

....does.

Change History (11)

comment:1 by Simon Charette, 12 years ago

Type: UncategorizedCleanup/optimization

Hi jendxb!

You are likely reading development version documentation while using a version of django <= 1.4.

The old behaviour of the url template tag will be officially deprecated in django 1.5 following the deprecation process described in the django 1.3 release note.

You should really convert your templates to use the new behaviour by adding the {% load url from future %} statement at the top of then.

Thanks for reporting anyway.

comment:2 by anonymous, 12 years ago

Type: Cleanup/optimizationBug

This tells me:

python -c "import django; print(django.get_version())"

...that I am running "1.4.1"

comment:3 by Simon Charette, 12 years ago

Resolution: invalid
Status: newclosed

The 1.4.X release branch still rely on the old behaviour by default.

I guess your report is against this part of the development version documentation. If you want this to work in 1.4.1 you must add a {% load url from future %} at the top of your template.

Again, I advise you to read the django 1.3 release note explaining this to understand why you encounter this error.

comment:4 by anonymous, 12 years ago

Type: BugUncategorized

Thanks for clarifying!

I had started with the Tutorial from the Django homepage and later googled to look up the Tutorial page I had been on last and ended up on the "dev" version of the documenation and as both look absolutely similar i didn't recognize that there are two versions of the tutorial ...I am sure I'll not be the only one falling for this, as the only difference is the additional "/dev" in the page URL.

Kudos btw to the person who wrote the Tutorial! One of the best I've ever seen.

comment:5 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

In [4da1d0fd65e01abe013e0d5a9174b81c6bbfa677]:

Added a warning about the {% url %} syntax change

at the point where it bites most beginners.

Refs #18787, #18762, #18756, #18723, #18705, #18689 and several duplicates.

comment:6 by cwilkes, 12 years ago

I think the /dev/ documentation would read better if it had the

{% load url from future %}

bit listed right above the

url 'polls.views.detail' poll.id

line if that's the way apps from 1.4 onward should be done.

As it is written everyone's going to run into the NoReverseMatch error page, look at the warning in the docs and become confused when it says that you're running a version < 1.4 when they are running 1.4.1.

comment:7 by Aymeric Augustin, 12 years ago

{% load url from future %} was only a transition tool. It isn't necessary in 1.5 any more.

For me ≤ 1.4 includes all the releases in the 1.4 series. I suppose it would be clearer to write < 1.5?

comment:8 by Aymeric Augustin, 12 years ago

Resolution: invalid
Status: closedreopened

comment:9 by Aymeric Augustin, 12 years ago

Owner: changed from nobody to Aymeric Augustin
Status: reopenednew

comment:10 by Tim Graham, 12 years ago

Triage Stage: UnreviewedAccepted

comment:11 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 98b6ce60f4f4456fb00259ec118e1fed2a4dfaa4:

Made a version condition less confusing.

Fixed #18762 (again).

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