#17551 closed Cleanup/optimization (invalid)
Namespaces declared in different places
| Reported by: | German M. Bravo | Owned by: | Grzegorz Nosek |
|---|---|---|---|
| Component: | Documentation | Version: | 1.4-alpha-1 |
| Severity: | Normal | Keywords: | |
| Cc: | German M. Bravo | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Currently, if the same namespace is declared for different included urls, only one included urls module gets the namespace.
In this scenario:
urlpatterns = patterns('',
url(r'^first/', include('first.urls')),
url(r'^first_default/', include('first.urls', app_name='first', namespace='first')),
url(r'^first_in_a/', include('first.urls', app_name='first', namespace='A')),
url(r'^first_in_b/', include('first.urls', app_name='first', namespace='B')),
url(r'^second/', include('second.urls')),
url(r'^second_default/', include('second.urls', app_name='second', namespace='second')),
url(r'^second_in_a/', include('second.urls', app_name='second', namespace='A')),
url(r'^second_in_b/', include('second.urls', app_name='second', namespace='B')),
)
The expected output is:
reverse('first') -> /first/
reverse('second') -> /second/
reverse('A:first') -> /first_in_a/
reverse('A:second') -> /second_in_a/
reverse('B:first') -> /first_in_b/
reverse('B:second') -> /second_in_b/
But instead is:
reverse('first') -> /first/
reverse('second') -> /second/
reverse('A:first') -> /first_in_a/
reverse('A:second') -> NoReverseMatch
reverse('B:first') -> /first_in_b/
reverse('B:second') -> NoReverseMatch
Attachments (3)
Change History (16)
by , 14 years ago
| Attachment: | #17551-multiple_namespaces.tar.bz2 added |
|---|
comment:1 by , 14 years ago
| Cc: | added |
|---|
by , 14 years ago
| Attachment: | #17551-multiple_namespaces.diff added |
|---|
Added tests (makes just two of them fail)
comment:2 by , 14 years ago
| Component: | Uncategorized → Core (URLs) |
|---|---|
| Has patch: | set |
| Owner: | changed from to |
| Patch needs improvement: | set |
| Status: | new → assigned |
by , 14 years ago
| Attachment: | 17551.diff added |
|---|
comment:3 by , 14 years ago
| Patch needs improvement: | unset |
|---|
comment:4 by , 14 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Bug |
comment:6 by , 14 years ago
| Version: | 1.3 → 1.4-alpha-1 |
|---|
comment:8 by , 14 years ago
| Severity: | Release blocker → Normal |
|---|
After further discussion, this isn't really a release blocker, since it isn't a regression or a major bug in a new feature.
However, the patch looks correct and stands a good chance to be committed before 1.4.
I've spend a few hours on it, but I don't feel sufficiently familiar with the URL namespacing feature to commit it. I asked Russell (the original author) if he could take a look.
comment:9 by , 13 years ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
After discussion with Malcolm (the other author), this rather looks like a misuse of app_name.
This could be resolved by improving the documentation rather than changing the code.
comment:10 by , 13 years ago
I really wish this could be checked in since, even of it's a "missuse" given the original design, I believe it to be a good addition which just further increases the url resolvers code isometry and flexibly by allowing the use of the same namespace name across apps... *plus* it doesn't really break anything, just covers what I believe to be a legit and intuitive use case for namespaces.
Any other thoughts about this ticket?
comment:11 by , 11 years ago
| Component: | Core (URLs) → Documentation |
|---|---|
| Has patch: | unset |
| Type: | Bug → Cleanup/optimization |
Moving to documentation based on Aymeric's comment 22. If someone wants to lobby for a design change, please start a thread on the DevelopersMailingList.
comment:12 by , 11 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | assigned → closed |
I think we can roll this documentation into #17707 - "Docs for URL namespaces should explain the motivation and use cases".
comment:13 by , 11 years ago
| Resolution: | duplicate → invalid |
|---|
It's documented that "Instance namespaces should be unique across your entire project." That seems to be the issue here.
Example which fails