Zeynel
Zeynel

Reputation: 13525

How to convert integer to string in a query in GAE?

If searchquery is an integer that I am getting from a form; how do I convert it to string? As far as I understand this is the reason why the following code is not working (it works if searchquery is a string:

p = Pet.all().filter('score =', self.request.get('searchquery')).fetch(10)

Thank you

Upvotes: 0

Views: 920

Answers (2)

Keshan
Keshan

Reputation: 14687

I think you need to convert an Integer to a string as far as i understand therefore use str(int) in this case : p = Pet.all().filter('score =', self.request.get(str('searchquery'))).fetch(10)

Upvotes: 0

Matt Ball
Matt Ball

Reputation: 359996

Is this Python? I'm assuming so. In which case, use int():

p = Pet.all().filter('score =', int(self.request.get('searchquery'))).fetch(10)

Upvotes: 2

Related Questions