我正在尝试此功能,但是出了点问题.我存储了名称“ John”,但是当我将john传递给username_并调用check_user时,即使该名称未存储在Google数据存储中,输出也始终会返回结果.为什么?
def check_user(self, username_):
query = db.Query(Registrations)
results = query.filter('username =', username_)
if results:
return results
user_username = self.request.get('username')
check_username_valid = self.check_user(user_username)
if not check_username_valid:
error_username_exists="Username already exists"
对于GQL,如何将变量username_传递到查询中?喜欢:
qr = db.GqlQuery("Select * from Registrations Where username = ?????")
解决方法:
结果是查询对象而不是结果,您需要调用query.filter(‘username =’,username _).get()返回单个结果,或者将query.filter(‘username =’,username _).fetch()返回全部归还.