diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-08-01 02:57:08 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-08-01 02:57:08 +0000 |
| commit | 1a428ec9b8efd24b0ced665d348160a9fd396c42 (patch) | |
| tree | 1613d638dd225bc6ab11ec6c1fde47c66a8706bb /docs | |
| parent | 0f977e974c071dbcf8235765be3fbbcde5e9b4e0 (diff) | |
Fixed #2370 -- It's now possible to pass default URLconf arguments to include(). Added docs, as well. Thanks for the patch, martin.glueck@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3506 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/url_dispatch.txt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/url_dispatch.txt b/docs/url_dispatch.txt index bc451ca628..6158014fc8 100644 --- a/docs/url_dispatch.txt +++ b/docs/url_dispatch.txt @@ -389,3 +389,45 @@ to pass metadata and options to views. .. _generic views: http://www.djangoproject.com/documentation/generic_views/ .. _syndication framework: http://www.djangoproject.com/documentation/syndication/ + +Passing extra options to ``include()`` +-------------------------------------- + +**New in the Django development version.** + +Similarly, you can pass extra options to ``include()``. When you pass extra +options to ``include()``, *each* line in the included URLconf will be passed +the extra options. + +For example, these two URLconf sets are functionally identical: + +Set one:: + + # main.py + urlpatterns = patterns('', + (r'^blog/', include('inner'), {'blogid': 3}), + ) + + # inner.py + urlpatterns = patterns('', + (r'^archive/$', 'mysite.views.archive'), + (r'^about/$', 'mysite.views.about'), + ) + +Set two:: + + # main.py + urlpatterns = patterns('', + (r'^blog/', include('inner')), + ) + + # inner.py + urlpatterns = patterns('', + (r'^archive/$', 'mysite.views.archive', {'blogid': 3}), + (r'^about/$', 'mysite.views.about', {'blogid': 3}), + ) + +Note that extra options will *always* be passed to *every* line in the included +URLconf, regardless of whether the line's view actually accepts those options +as valid. For this reason, this technique is only useful if you're certain that +every view in the the included URLconf accepts the extra options you're passing. |
