摘要:
原权限判断代码 def check_permissions(self, request): """ Check if the request should be permitted. Raises an appropriate exception if the request is not perm 阅读全文
摘要:
组件类(返回True为通过) from rest_framework.permissions import BasePermission class DemoPermission(BasePermission): # 自定义失败的返回信息 message = {"status": False, 'c 阅读全文
摘要:
建表 from django.db import models class UserInfo(models.Model): username = models.CharField(verbose_name='用户名', max_length=32) password = models.CharFie 阅读全文
摘要:
class BaseAuthentication: """ All authentication classes should extend BaseAuthentication. """ def authenticate(self, request): """ 如果子类继承BaseAuthenti 阅读全文
摘要:
现象 # 兜底认证,直接失败 class NoAuthentication(BaseAuthentication): def authenticate(self, request): raise AuthenticationFailed('认证失败') class AuthenticationFai 阅读全文