Code

Opened 7 months ago

Closed 7 months ago

Last modified 6 months ago

#21582 closed Bug (fixed)

URL namespaces and included URLconfs: the example might be confusing

Reported by: oubiga Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords: url, include, URLconf, documentation
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the example, https://docs.djangoproject.com/en/1.6/topics/http/urls/#url-namespaces-and-included-urlconfs says:

from django.conf.urls import include, patterns, url

help_patterns = patterns('',
    url(r'^basic/$', 'apps.help.views.views.basic'),
    url(r'^advanced/$', 'apps.help.views.views.advanced'),
)

url(r'^help/', include(help_patterns, 'bar', 'foo')),

In this case, I think arg from the include function has to be a 3-tuple:

url(r'^help/', include((help_patterns, 'bar', 'foo'))),

Attachments (0)

Change History (6)

comment:1 Changed 7 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Have you verified what actually works? If your suggestion doesn't work, we should at least amend the wording about a 3-tuple because I agree that's misleading.

comment:2 Changed 7 months ago by timo

The existing code is indeed incorrect. The signature of include is include(arg, namespace=None, app_name=None) so while (help_patterns, 'bar', 'foo') will work, it mixes up the application and instances namespaces as compared to passing the values as a tuple. I've added a warning about making this mistake in addition to correcting the example.

comment:3 Changed 7 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 025ec2e7fe3f4056835eda94d204ec87901fa11f:

Fixed #21582 -- Corrected URL namespace example.

Thanks oubiga for the report.

comment:4 Changed 7 months ago by Tim Graham <timograham@…>

In f3a9a761238977b7db9a2f8449207cd439be235e:

[1.6.x] Fixed #21582 -- Corrected URL namespace example.

Thanks oubiga for the report.

Backport of 025ec2e7fe from master

comment:5 Changed 7 months ago by Tim Graham <timograham@…>

In 66ada281d5842da82f1fdc813b941ebb04dec6e3:

[1.5.x] Fixed #21582 -- Corrected URL namespace example.

Thanks oubiga for the report.

Backport of 025ec2e7fe from master

comment:6 Changed 6 months ago by oubiga

Tim, I'm late... sorry.
Working with you is always a pleasure.

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.