Closed
Description
If we look at it from a conceptual perspective, you’re right. However in that case, we should update the section "Introspecting ViewSet actions" to avoid similar discussions in the future and save DRF users time.
I suggest update this section like this:
## Introspecting ViewSet actions
During dispatch, the following attributes are available on the `ViewSet`.
* `basename` - the base to use for the URL names that are created.
* `action` - the name of the current action (e.g., `list`, `create`).
* `detail` - boolean indicating if the current action is configured for a list or detail view.
* `suffix` - the display suffix for the viewset type - mirrors the `detail` attribute.
* `name` - the display name for the viewset. This argument is mutually exclusive to `suffix`.
* `description` - the display description for the individual view of a viewset.
You may inspect these attributes to adjust behavior based on the current action.
**Note**: don`t use the `action` attribute in the `get_parsers`, `get_authenticators` or `get_content_negotiator` methods, otherwise you will get an `AttributeError` error.
Originally posted by @EXG1O in #9614 (reply in thread)
Metadata
Metadata
Assignees
Labels
No labels