aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/viewsets.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api-guide/viewsets.md')
-rw-r--r--docs/api-guide/viewsets.md11
1 files changed, 8 insertions, 3 deletions
diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md
index cd92dc58..2783da98 100644
--- a/docs/api-guide/viewsets.md
+++ b/docs/api-guide/viewsets.md
@@ -34,7 +34,7 @@ Let's define a simple viewset that can be used to list or retrieve all the users
serializer = UserSerializer(user)
return Response(serializer.data)
-If we need to, we can bind this viewset into two seperate views, like so:
+If we need to, we can bind this viewset into two separate views, like so:
user_list = UserViewSet.as_view({'get': 'list'})
user_detail = UserViewSet.as_view({'get': 'retrieve'})
@@ -65,7 +65,7 @@ Both of these come with a trade-off. Using regular views and URL confs is more
The default routers included with REST framework will provide routes for a standard set of create/retrieve/update/destroy style operations, as shown below:
- class UserViewSet(viewsets.VietSet):
+ class UserViewSet(viewsets.ViewSet):
"""
Example empty viewset demonstrating the standard
actions that will be handled by a router class.
@@ -92,7 +92,7 @@ The default routers included with REST framework will provide routes for a stand
def destroy(self, request, pk=None):
pass
-If you have ad-hoc methods that you need to be routed to, you can mark them as requiring routing using the `@link` or `@action` decorators. The `@link` decorator will route `GET` requests, and the `@action` decroator will route `POST` requests.
+If you have ad-hoc methods that you need to be routed to, you can mark them as requiring routing using the `@link` or `@action` decorators. The `@link` decorator will route `GET` requests, and the `@action` decorator will route `POST` requests.
For example:
@@ -126,6 +126,11 @@ The `@action` and `@link` decorators can additionally take extra arguments that
def set_password(self, request, pk=None):
...
+The `@action` decorator will route `POST` requests by default, but may also accept other HTTP methods, by using the `method` argument. For example:
+
+ @action(methods=['POST', 'DELETE'])
+ def unset_password(self, request, pk=None):
+ ...
---
# API Reference