Tag: tastypie

我如何使用tastypielogin到Django

我想重写is_authenticated在我的自定义身份validation。 我有一些简单的(开始)像这样: class MyAuthentication(BasicAuthentication): def __init__(self, *args, **kwargs): super(MyAuthentication, self).__init__(*args, **kwargs) def is_authenticated(self, request, **kwargs): return True 然后在我的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() 我一直得到一个500错误返回"error_message": "column username is not unique" 。 我只有一个用户名在数据库中,这是我想要validation的用户。 任何想法,为什么它返回这个错误? 我将如何让api客户端login? 谢谢您的帮助。