Skip to content

Commit

Permalink
Update documentation to mention HTTPMethod support in @action
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkraleu committed Aug 11, 2023
1 parent 47d3873 commit a294a45
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/api-guide/viewsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`...:

Expand Down

0 comments on commit a294a45

Please sign in to comment.