Peewee:如何在表单提交上验证登录详细信息

时间:2014-12-24 09:56:26

标签: python sqlite peewee

目前我正在开展这个项目。我是新的蟒蛇,小便。

我需要检查给定的登录凭据是否有效?

我搜索了很多网站来找到这个ans。但我得到的确切是我想要的?

在下面找到我做的事情:

def process(self):
    email = self.get_argument("username")
    password = self.get_argument("password")
    print Email, Password
    try:
        result = Employee.select().where(Employee.Email_ID == email , Employee.Password == password)
        print 'Query is ', result
        if result == None:
            print 'Failure'
        else:
            print 'Success'
    except Exception as e:
        print(e)
    return self.render_template("index.py")
你可以帮我解决这个问题吗?我做错了? 提前致谢

1 个答案:

答案 0 :(得分:-1)

在Python中检查无结果时,尝试与“是”进行比较。

if result is None:
    .....

将“引用”检查为“无”更有效。

我认为您错误在其中方法。

.where(Employee.Email_ID == email , Employee.Password == password)

也许,

.where(Employee.Email_ID = email , Employee.Password = password)