Neo10373 最近的时间轴更新
Neo10373

Neo10373

V2EX 第 393477 号会员,加入于 2019-03-19 16:45:31 +08:00
Neo10373 最近回复了
2020-10-15 09:05:28 +08:00
回复了 knight3r 创建的主题 Django 对同一 viewset 的不同 action 方法不同的 authenticaltion 是否可行?
create,retrieve 等默认 action 是不行的, 会自动使用 UserViewSet 的 authentication_classes,

1. 要么关闭视图类属性的 authentication_classes, 每个 action 内自己使用 JwtAuthorizationAuthentication 进行认证
2. 要么去掉 CreateModelMixin, RetrieveModelMixin, 自己写 action
```
@action(detail=False, authentication_classes=(JwtAuthorizationAuthentication, ))
def my_create(self, request, *args, **kwargs):

@action(detail=True, authentication_classes=())
def my_retrieve(self, request, *args, **kwargs):
```
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2698 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 1506ms · UTC 11:02 · PVG 19:02 · LAX 04:02 · JFK 07:02
Developed with CodeLauncher
♥ Do have faith in what you're doing.