开发者

how to get the info which contains 'sss', not "= ",

this is my code:

class Marker_latlng(db.Model):
    geo_pt = db.GeoPtProperty()

class Marker_info(db.Model):
    info = db.StringProperty()
    marker_latlng =db.ReferenceProperty(Marker_latlng)

q = Marker_info.all()
q.filter("info =", "sss")

but how to get the info which contains 'sss', not "=",

has a method like开发者_如何转开发 "contains "?

    q = Marker_info.all()
    q.filter("info contains", "sss")


Instead of using a StringProperty, you could use a StringListProperty. Before saving the info string, split it into a list of strings, containing each word.

Then, when you use q.filter("info =", "sss") it will match any item which contains a word which is each to "sss".

For something more general, you could look into app engine full text search.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜