#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 , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Bug |
comment:2 by , 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 , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.