mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-12-04 16:54:02 +03:00
Add warning for .as_view() with @action. Fixes #9638
This commit is contained in:
parent
577bb3c819
commit
199e5a9317
|
|
@ -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')
|
router.register(r'users', UserViewSet, basename='user')
|
||||||
urlpatterns = router.urls
|
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:
|
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):
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user