摘要: 实现效果:除登录接口无需认证,其他接口如果从params或者头部AUTHORIZATION没有获取到token,则直接认证失败。如果去掉NoAuthentication,则支持匿名访问 认证类 from rest_framework.authentication import BaseAuthent 阅读全文
posted @ 2022-09-30 20:13 Sherwin_szw 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 认证类(不能写在视图里) rom rest_framework.authentication import BaseAuthentication from rest_framework.exceptions import AuthenticationFailed class MyAuthentica 阅读全文
posted @ 2022-09-30 14:34 Sherwin_szw 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-09-30 11:31 Sherwin_szw 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 路由 urlpatterns = [ path('order/', views.OrderView.as_view()), ] 视图关系 class View(object): @classonlymethod def as_view(cls, **initkwargs): def view(req 阅读全文
posted @ 2022-09-30 10:11 Sherwin_szw 阅读(13) 评论(0) 推荐(0) 编辑