Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21582 closed Bug (fixed)

URL namespaces and included URLconfs: the example might be confusing

Reported by: Pablo Oubiña 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'))),

Change History (6)

comment:1 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

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 by Tim Graham, 11 years ago

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 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 025ec2e7fe3f4056835eda94d204ec87901fa11f:

Fixed #21582 -- Corrected URL namespace example.

Thanks oubiga for the report.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In f3a9a761238977b7db9a2f8449207cd439be235e:

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

Thanks oubiga for the report.

Backport of 025ec2e7fe from master

comment:5 by Tim Graham <timograham@…>, 11 years ago

In 66ada281d5842da82f1fdc813b941ebb04dec6e3:

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

Thanks oubiga for the report.

Backport of 025ec2e7fe from master

comment:6 by Pablo Oubiña, 11 years ago

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

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