From e1119f2d9a23534cdb42f9b1373ea8f13de8a462 Mon Sep 17 00:00:00 2001 From: Pavel Kral Date: Fri, 11 Aug 2023 11:34:19 +0200 Subject: [PATCH] Update documentation to mention HTTPMethod support in @action --- docs/api-guide/viewsets.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index 5d5491a83..39db18bca 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -178,6 +178,13 @@ The `action` decorator will route `GET` requests by default, but may also accept def unset_password(self, request, pk=None): ... +Argument `methods` also supports HTTP methods defined as [HTTPMethod](https://docs.python.org/3/library/http.html#http.HTTPMethod). Example below is identical to the one above: + + from http import HTTPMethod + + @action(detail=True, methods=[HTTPMethod.POST, HTTPMethod.DELETE]) + def unset_password(self, request, pk=None): + ... The decorator allows you to override any viewset-level configuration such as `permission_classes`, `serializer_class`, `filter_backends`...: