Skip to content

Commit 8f821dc

Browse files
committed
Provide both app and instance namespace examples
1 parent a0528fd commit 8f821dc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

docs/api-guide/routers.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,21 @@ Alternatively you can use Django's `include` function, like so…
7272
url(r'^', include(router.urls)),
7373
]
7474

75-
To include the router URL patterns with an application namespace pass a
76-
`(router.urls, 'app_name')` 2-tuple to `include`.
77-
78-
For example:
75+
You may use `include` with an application namespace:
7976

8077
urlpatterns = [
8178
url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
8279
url(r'^api/', include((router.urls, 'app_name'))),
8380
]
8481

85-
(You may additionally pass an optional `namespace` parameter to `include` to also
86-
create an _instance namespace_. See Django's [URL namespaces docs][url-namespace-docs] for more details.)
82+
Or both an application and instance namespace:
83+
84+
urlpatterns = [
85+
url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
86+
url(r'^api/', include((router.urls, 'app_name'), namespace='instance_name')),
87+
]
88+
89+
See Django's [URL namespaces docs][url-namespace-docs] and the [`include` API reference][include-api-reference] for more details.
8790

8891
If using namespacing with hyperlinked serializers you'll also need to ensure that any `view_name` parameters on the serializers correctly reflect the namespace.
8992
In the example above you'd need to include a parameter such as `view_name='app_name:user-detail'` for serializer fields hyperlinked to the user detail view.

0 commit comments

Comments
 (0)