Code

#18939 closed Uncategorized (invalid)

usage of url template tag under-documented

Reported by: jdzero Owned by: nobody
Component: Documentation Version: master
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

Hello,
While learning about the {% url %} template tag, I found the documentation to be inadequate in one section and incorrect in another. Forums answered my question, but I just wanted to bring it to your attention. I have the snippets below.
Thanks, John

https://docs.djangoproject.com/en/dev/ref/templates/builtins/

Reads
If you're using named URL patterns, you can refer to the name of the pattern in the url tag instead of using the path to the view.

Recommend
If you're using named URL patterns, you can refer to the name of the pattern in the url tag without quotation marks instead of using the path to the view.

https://docs.djangoproject.com/en/dev/topics/http/urls

Reads
Here's the above example, rewritten to use named URL patterns:

urlpatterns = patterns(' ',

url(..., name="full-archive"),
url(..., "arch-summary"),

)

With these names in place (full-archive and arch-summary), you can target each pattern individually by using its name:

{% url 'arch-summary' 1945 %}
{% url 'full-archive' 2007 %}

Recommend
{% url arch-summary 1945 %}
{% url full-archive 2007 %}

Attachments (0)

Change History (1)

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

Thanks for the report, but the documentation is correct.

You aren't reading the documentation for the version of Django you're using.

See:

Last edited 20 months ago by aaugustin (previous) (diff)

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.