我正在通过web2py创建一个产品评论网站,并且在添加搜索功能时遇到了困难。这是我到目前为止的代码:
def index():
rows = db(db.reviews).select()
name_default = request.vars.name
body_default = request.vars.body
objects_default = request.vars.objects
form = SQLFORM.factory(
Field("Item Name", default = name_default),
Field("Body", default = body_default),
Field("Objects", default = objects_default),
formstyle = 'divs'
submit_button = "Search"
)
query = db.db1.id_user == auth.user_id
if form.process().accepted:
name = form.vars.name
body = form.vars.body
objects = form.vars.objects
count = db(query).count()
results = db(query).select(orderby=~db.db1.data)
msg = T("%s registers" % count)
return dict(form=form, msg=msg, results=results)
return locals()
我得到的错误是第23行28字符(submit_button = "Search"
行)的语法错误。