aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/routers.md
diff options
context:
space:
mode:
authorTom Christie2015-01-30 14:00:25 +0000
committerTom Christie2015-01-30 14:00:25 +0000
commit4ee4b4f2dc3cffd8246772bdf829a2a720493377 (patch)
tree95b514483e901c10bdeee0d66e60430002d5101a /docs/api-guide/routers.md
parent8f33e39f62c59d06783dd3e6e7cf8d464ff08c5f (diff)
parent7cf9dea7f905ea6869148a68b4fa96cad0a347e8 (diff)
downloaddjango-rest-framework-4ee4b4f2dc3cffd8246772bdf829a2a720493377.tar.bz2
Merge master
Diffstat (limited to 'docs/api-guide/routers.md')
-rw-r--r--docs/api-guide/routers.md12
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index 9c9bfb50..592f7d66 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -28,7 +28,7 @@ There are two mandatory arguments to the `register()` method:
Optionally, you may also specify an additional argument:
-* `base_name` - The base to use for the URL names that are created. If unset the basename will be automatically generated based on the `model` or `queryset` attribute on the viewset, if it has one. Note that if the viewset does not include a `model` or `queryset` attribute then you must set `base_name` when registering the viewset.
+* `base_name` - The base to use for the URL names that are created. If unset the basename will be automatically generated based on the `queryset` attribute of the viewset, if it has one. Note that if the viewset does not include a `queryset` attribute then you must set `base_name` when registering the viewset.
The example above would generate the following URL patterns:
@@ -60,7 +60,7 @@ For example, you can append `router.urls` to a list of existing views…
router.register(r'accounts', AccountViewSet)
urlpatterns = [
- url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
+ url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
]
urlpatterns += router.urls
@@ -68,15 +68,15 @@ For example, you can append `router.urls` to a list of existing views…
Alternatively you can use Django's `include` function, like so…
urlpatterns = [
- url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
- url(r'^', include(router.urls))
+ url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
+ url(r'^', include(router.urls)),
]
Router URL patterns can also be namespaces.
urlpatterns = [
- url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
- url(r'^api/', include(router.urls, namespace='api'))
+ url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
+ url(r'^api/', include(router.urls, namespace='api')),
]
If using namespacing with hyperlinked serializers you'll also need to ensure that any `view_name` parameters on the serializers correctly reflect the namespace. In the example above you'd need to include a parameter such as `view_name='api:user-detail'` for serializer fields hyperlinked to the user detail view.