一.rest-framework登录验证 1.models.py添加User和Token模型 class User(models.Model): name = models.CharField(max_length=32) pwd = models.CharField(max_length=32) class Token(models.Model): user = models.OneToOneField("User", on_delete=models.CASCADE) token…
认证组件 局部视图认证 在app01.service.auth.py: class Authentication(BaseAuthentication): def authenticate(self,request): token=request._request.GET.get("token") token_obj=UserToken.objects.filter(token=token).first() if not token_obj: raise exceptions.Auth…