I am trying this function, however something is wrong. I stored the name “John” but when i pass the john to username_ and call the check_user the output is always return results, even if the name is not stored in google data store. Why?
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"
In the case of GQL, how can i pass the variable username_ into the query? like:
qr = db.GqlQuery("Select * from Registrations Where username = ?????")
results is the query object not the result, you need to call
query.filter('username =', username_).get()to return a single result orquery.filter('username =', username_).fetch()to return all of them.