#26288: Support relative imports in django.conf.urls.include
-----------------------------+-----------------------------------------
Reporter: lamby | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 1.9
Severity: Normal | Resolution:
Keywords: urls | Triage Stage: Someday/Maybe
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-----------------------------------------
Comment (by lamby):
> Any problem with that approach?
Well, firstly it's extra stuff you have to explicitly import which seems a
style regression from the "oh just use these included urls" that you get
with the string-based import.
Secondly, whilst it might look fine when you are doing it once, for
example:
{{{
from django.conf.urls import url, include
from . import views
from .foo import urls
urlpatterns = (
url(r'', include(urls, namespace='foo')),
url(r'^$', views.landing, name='landing'),
)
}}}
.. but the import dance get a bit nasty when you have multiple ones - you
have to alias each import:
{{{
from django.conf.urls import url, include
from . import views
from .foo_app import urls as foo_urls
from .bar_app import urls as bar_urls
# etc.
urlpatterns = (
url(r'', include(foo_urls, namespace='foo')),
url(r'', include(bar_urls, namespace='bar')),
url(r'^$', views.landing, name='landing'),
)
}}}
This isn't an readabiliy improvement over using the string urls IMHO.
Now, if only we could do the following:
{{{
from . import views, foo_app, bar_app
urlpatterns = (
url(r'', include(foo_app.urls), namespace='foo')),
url(r'', include(bar_app.urls), namespace='bar')),
url(r'^$', views.landing, name='landing'),
)
}}}
:(
--
Ticket URL: <https://code.djangoproject.com/ticket/26288#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.01226d5184d52a7031f8a7c23fd81383%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.