Code

Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#18787 closed Uncategorized (invalid)

Tutorial code incorrect

Reported by: Foxpaw Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal 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

Running through the tutorial, the document at https://docs.djangoproject.com/en/dev/intro/tutorial03/ towards the bottom presents the following code when explaining how to not hardcode URLs in your templates:

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

This code is actually wrong. The quotes around polls.views.detail are not needed, and in fact cause the template to throw an error. The proper code should be:

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

Attachments (0)

Change History (2)

comment:1 Changed 20 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

You are likely reading the 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 notes.

Thanks for reporting anyway.

comment:2 Changed 20 months ago by Aymeric Augustin <aymeric.augustin@…>

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.