def decorated_patterns(func, *urls):
def decorate(urls, func):<EOL><INDENT>for url in urls:<EOL><INDENT>if isinstance(url, RegexURLPattern):<EOL><INDENT>url.__class__ = DecoratedURLPattern<EOL>if not hasattr(url, "<STR_LIT>"):<EOL><INDENT>setattr(url, "<STR_LIT>", [])<EOL><DEDENT>url._decorate_with.append(func)<EOL><DEDENT>elif isinstance(url, RegexURLResolver):<EOL><INDENT>for pp in url.url_patterns:<EOL><INDENT>if isinstance(pp, RegexURLPattern):<EOL><INDENT>pp.__class__ = DecoratedURLPattern<EOL>if not hasattr(pp, "<STR_LIT>"):<EOL><INDENT>setattr(pp, "<STR_LIT>", [])<EOL><DEDENT>pp._decorate_with.append(func)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if func:<EOL><INDENT>if not isinstance(func, (list, tuple)):<EOL><INDENT>func = [func]<EOL><DEDENT>for f in func:<EOL><INDENT>decorate(urls, f)<EOL><DEDENT><DEDENT>return urls<EOL>
Utility function to decorate a group of url in urls.py

Taken from http://djangosnippets.org/snippets/532/ + comments
See also http://friendpaste.com/6afByRiBB9CMwPft3a6lym

Example:
urlpatterns = [
    url(r'^language/(?P<lang_code>[a-z]+)$', views.MyView, name='name'),
] + decorated_patterns(login_required, url(r'^', include('cms.urls')),