[英]login(request, user) function not working in django.contrib.auth
I am currently building a web app using Django that requires users to login, and I have this function in views.py我目前正在使用 Django 构建一个需要用户登录的网络应用程序,我在 views.py 中有这个功能
def post(self, request, format=None):
login = request.data
user = authenticate(
username=login['username'], password=login['password'])
if user is not None:
login(request, user)
return Response({'message': 'Login successful', 'status': 1})
else:
return Response({'message': 'Login unsuccessful', 'status': 0})
But the login function keeps triggering an error但是登录功能不断触发错误
File ".../views.py", line 58, in post
login(request, user)
TypeError: 'dict' object is not callable
I don't know why the user is identified as 'dict' object.我不知道为什么用户被标识为 'dict' 对象。 Can please anyone help me?
可以请任何人帮助我吗?
login = request.data登录 = request.data
changing the variable name will work.更改变量名称将起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.