From cfc067be30db46f5fc47b1f4e7f8d7dd1987a112 Mon Sep 17 00:00:00 2001 From: Mahdi <111646898+mahdighadiriii@users.noreply.github.com> Date: Tue, 9 Dec 2025 12:29:11 +0330 Subject: [PATCH] Add warning regarding `.as_view()` with `ViewSet` action in the documentation (#9823) --- docs/api-guide/viewsets.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index 102bac40e..08b3f5b10 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -57,6 +57,8 @@ Typically we wouldn't do this, but would instead register the viewset with a rou router.register(r'users', UserViewSet, basename='user') urlpatterns = router.urls +**Warning**: Do not use `.as_view()` with `@action` methods. It bypasses router setup and may ignore action settings like `permission_classes`. Use `DefaultRouter` for actions. + Rather than writing your own viewsets, you'll often want to use the existing base classes that provide a default set of behavior. For example: class UserViewSet(viewsets.ModelViewSet):