def operator_logincheck_web(request, email=None):
data = json.loads
email = data['email']
email = email.lower()
password = data['password']
if Operator.objects.filter(email = email).count() > 0:
if Operator.objects.filter(email = email, password = password).count() > 0:
loginobj = Operator.objects.get(email = email, password = password)
send_data = {'status':"1", 'msg':"Login Successfull", 'user_id':str(loginobj.id)}
else:
send_data = {'status':"0", 'msg':"Incorrect Password"}
else:
send_data = {'status':"0", 'msg':"Incorrect Email"}
return JsonResponse(send_data)
但是在操作员登录检查web中的终端文件“/home/sumit/Cricket/CricketApp/views.py”第1443行中获取此错误 电子邮件=数据['email'] TypeError:“函数”对象不可下标
嗯,json.loads是一个函数,您已经将它赋回变量调用
data
,并且您正在从中查找email
属性。您可以通过以下方式从request
对象中查找有效负载:从错误中吸取教训
Python程序中的每个数据都由对象或对象之间的关系表示
这就是Pythondocumentation对对象的描述
Python的函数是一流的对象。这意味着,(参考:Dan Bader)
Python支持高阶函数。这意味着,(参考:Wikipedia)
如果你不在这里发表评论,我希望你能理解这里发生了什么。您可以从Primer on Python Decorators文章中了解到许多与上述概念相关的内容
参考资料:-
相关问题 更多 >
编程相关推荐