﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24074	Addition: Url convenience function	Martin Owens	nobody	"We're using a convenience function in our website urls and I want to propose it's inclusion into django upstream. I'm sounding out developers feelings on such an addition before I generate a patch and connected documentation.

Code (for django.conf.urls):
{{{
def url_tree(regex, *urls):
    return url(regex, include(patterns('', *urls)))
}}}

This function cleans up url definitions that contain multiple layers. For example if you had a urls file containing:
{{{
urlpatterns = patterns('',
  url(r'^$', MyListView.as_view()),
  url(r'^(?P<pk>\d+)/$', MyItemView.as_view()),
  url(r'^(?P<pk>\d+)/delete/$', MyDeleteView.as_view()),
  url(r'^(?P<pk>\d+)/post/$', MyPostView.as_view()),
)
}}}

And DRY it into:
{{{
urlpatterns = patterns('',
  url(r'^$', MyListView.as_view()),
  url_tree(r'^(?P<pk>\d+)/',
    url('^$', MyItemView.as_view()),
    url(r'^delete/$', MyDeleteView.as_view()),
    url(r'^post/$', MyPostView.as_view()),
  ),
)
}}}
This function gets very useful with tens of possible functions and long urls. So. Does this make sense as an addition to django? Is the functionality already there an I've missed it? Let me know."	New feature	closed	Core (URLs)	1.6	Normal	wontfix			Unreviewed	1	0	0	0	1	0
