gpt4 book ai didi

python - 在Google App Engine中,如何使用python通过 bool 值进行查询?

转载 作者:太空宇宙 更新时间:2023-11-03 18:41:32 25 4
gpt4 key购买 nike

“checked”被分配了 BooleanProperty 并具有默认值 False。

在 post 方法中,如果选中实体的复选框,我会重置“已选中”

def post(self):
sells = SellModel.all()

boxcount = 0
for sell in sells:
checkbox = self.request.get('checkbox')
if checkbox:
sell.checked = True
boxcount += 1

if boxcount == 0:
error = "check at least one box"
self.render("buy.html", error = error, sells = sells)
else:
self.redirect('/contact')

然后我尝试了以下调用

cart = SellModel.all().filter("checked =", True)

cart = SellModel.all().filter("checked !=", False)

cart = SellModel.all().filter("checked >", False)

这一切都不起作用。但是,当我查询时检查为 false,如

cart = SellModel.all().filter("checked =", False)

它有效...发生了什么事?我认为将“sell.checked = True”放入这样的 for 循环中会将销售条目的“checked”设置为 true

最佳答案

刚刚意识到 sell.checked = True 实际上并没有更新对象。我添加了 卖出.put()它起作用了。

关于python - 在Google App Engine中,如何使用python通过 bool 值进行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20412971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com