URL namespacing improvements
|Reported by:||aaugustin||Owned by:||knbk|
|Cc:||real.human@…, bendavis78, dries@…, apollo13, info+coding@…, marten.knbk@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I discussed URL namespacing with Malcolm at DjangoCon US 2012. I took some notes on the current design and possible improvements.
Unfortunately, I haven't found the time and motivation to actually work on these improvements since then. I just mentioned them in #20734.
I'm including below a slightly edited version of my notes. Not everything is clear, but that's all I have, and I don't remember anything else.
URL namespaces only exist for the purpose of reversing. They're "names for groups of URLs".
(They're analogous to XML namespaces in this regard.)
- Apps need to be able to reverse their own URLs, even if there are several instances installed.
- It must be possible to find the default instance of an app.
- It must be possible to find a specific instance of an app.
Application vs. instance namespaces
An application namespace = app_name
- There can be only one in a given project.
- The only use case for not using the application label is name conflicts.
- Shouldn't it be eventually moved to app._meta? (not sure about what I meant there)
An instance namespace = namespace
- It differentiate instances of the same application.
1) Clarify documentation
2) Make it possible to reverse without specifying the namespace and document this pattern:
urlpatterns = ( url(r'^foo/', include('foo.urls', namespace='foo')), )
This requires a way to specifiy the default namespace. It would supersede #11642.
Change History (19)
comment:5 Changed 17 months ago by bendavis78
comment:14 Changed 5 months ago by knbk
- Cc marten.knbk@… added
- Owner changed from nobody to knbk
- Status changed from new to assigned
comment:18 Changed 4 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from assigned to closed