Skip to content

Commit f8dbea1

Browse files
EXG1Obrowniebroke
andauthored
Add note in 'Introspecting ViewSet actions' docs section (#9633)
* Fix `Introspecting ViewSet actions` docs section * Update docs/api-guide/viewsets.md --------- Co-authored-by: Bruno Alla <[email protected]>
1 parent e1c070a commit f8dbea1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/api-guide/viewsets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ You may inspect these attributes to adjust behavior based on the current action.
128128
permission_classes = [IsAdminUser]
129129
return [permission() for permission in permission_classes]
130130

131+
**Note**: the `action` attribute is not available in the `get_parsers`, `get_authenticators` and `get_content_negotiator` methods, as it is set _after_ they are called in the framework lifecycle. If you override one of these methods and try to access the `action` attribute in them, you will get an `AttributeError` error.
132+
131133
## Marking extra actions for routing
132134

133135
If you have ad-hoc methods that should be routable, you can mark them as such with the `@action` decorator. Like regular actions, extra actions may be intended for either a single object, or an entire collection. To indicate this, set the `detail` argument to `True` or `False`. The router will configure its URL patterns accordingly. e.g., the `DefaultRouter` will configure detail actions to contain `pk` in their URL patterns.

0 commit comments

Comments
 (0)