aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/routers.md
diff options
context:
space:
mode:
authorTom Christie2013-08-19 20:36:18 +0100
committerTom Christie2013-08-19 20:36:18 +0100
commitc607414f1637221486a6f13c6ce0d64dbe95957b (patch)
tree39160b6c4bbd4af7b251907f0d5314c468230dc4 /docs/api-guide/routers.md
parent34d65119fc1c200b76a8af7213a92d6b279bd478 (diff)
parenteaae8fb2d973769a827214e0606a7e41028d5d34 (diff)
downloaddjango-rest-framework-c607414f1637221486a6f13c6ce0d64dbe95957b.tar.bz2
Merge
Diffstat (limited to 'docs/api-guide/routers.md')
-rw-r--r--docs/api-guide/routers.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index 072a2e79..7884c2e9 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -35,12 +35,12 @@ The example above would generate the following URL patterns:
* URL pattern: `^accounts/$` Name: `'account-list'`
* URL pattern: `^accounts/{pk}/$` Name: `'account-detail'`
-### Extra link and actions
+### Registering additional routes
-Any methods on the viewset decorated with `@link` or `@action` will also be routed.
+Any methods on the viewset decorated with `@detail_route` or `@list_route` will also be routed.
For example, given a method like this on the `UserViewSet` class:
- @action(permission_classes=[IsAdminOrIsSelf])
+ @detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf])
def set_password(self, request, pk=None):
...
@@ -52,7 +52,7 @@ The following URL pattern would additionally be generated:
## SimpleRouter
-This router includes routes for the standard set of `list`, `create`, `retrieve`, `update`, `partial_update` and `destroy` actions. The viewset can also mark additional methods to be routed, using the `@link` or `@action` decorators.
+This router includes routes for the standard set of `list`, `create`, `retrieve`, `update`, `partial_update` and `destroy` actions. The viewset can also mark additional methods to be routed, using the `@detail_route` or `@list_route` decorators.
<table border=1>
<tr><th>URL Style</th><th>HTTP Method</th><th>Action</th><th>URL Name</th></tr>
@@ -62,8 +62,8 @@ This router includes routes for the standard set of `list`, `create`, `retrieve`
<tr><td>PUT</td><td>update</td></tr>
<tr><td>PATCH</td><td>partial_update</td></tr>
<tr><td>DELETE</td><td>destroy</td></tr>
- <tr><td rowspan=2>{prefix}/{lookup}/{methodname}/</td><td>GET</td><td>@link decorated method</td><td rowspan=2>{basename}-{methodname}</td></tr>
- <tr><td>POST</td><td>@action decorated method</td></tr>
+ <tr><td rowspan=2>{prefix}/{lookup}/{methodname}/</td><td>GET</td><td>@detail_route decorated method</td><td rowspan=2>{basename}-{methodname}</td></tr>
+ <tr><td>POST</td><td>@detail_route decorated method</td></tr>
</table>
By default the URLs created by `SimpleRouter` are appended with a trailing slash.
@@ -86,8 +86,8 @@ This router is similar to `SimpleRouter` as above, but additionally includes a d
<tr><td>PUT</td><td>update</td></tr>
<tr><td>PATCH</td><td>partial_update</td></tr>
<tr><td>DELETE</td><td>destroy</td></tr>
- <tr><td rowspan=2>{prefix}/{lookup}/{methodname}/[.format]</td><td>GET</td><td>@link decorated method</td><td rowspan=2>{basename}-{methodname}</td></tr>
- <tr><td>POST</td><td>@action decorated method</td></tr>
+ <tr><td rowspan=2>{prefix}/{lookup}/{methodname}/[.format]</td><td>GET</td><td>@detail_route decorated method</td><td rowspan=2>{basename}-{methodname}</td></tr>
+ <tr><td>POST</td><td>@detail_route decorated method</td></tr>
</table>
As with `SimpleRouter` the trailing slashes on the URL routes can be removed by setting the `trailing_slash` argument to `False` when instantiating the router.