我试图在我的自定义身份验证中覆盖is_authenticated.我有一些简单的(开始)像这样:
class MyAuthentication(BasicAuthentication):
def __init__(self, *args, **kwargs):
super(MyAuthentication, self).__init__(*args, **kwargs)
def is_authenticated(self, request, **kwargs):
return True
Run Code Online (Sandbox Code Playgroud)
然后在我的ModelResource中
class LoginUserResource(ModelResource):
class Meta:
resource_name = 'login'
queryset = User.objects.all()
excludes = ['id', 'email', 'password', 'is_staff', 'is_superuser']
list_allowed_methods = ['post']
authentication = MyAuthentication()
authorization = DjangoAuthorization()
Run Code Online (Sandbox Code Playgroud)
我一直收到500错误"error_message": "column username is not unique".我在数据库中只有一个用户名,而我正在尝试进行身份验证.
关于它为什么会返回此错误的任何想法?我如何允许api客户端登录?
谢谢您的帮助.