I am currently building a web app using Django that requires users to login, and I have this function in 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. Can please anyone help me?
login = request.data
changing the variable name will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.