我需要从sqlalchemy
进行搜索,并使用搜索结果
这里的代码,从模态表单提交搜索
<div class="modal-body">
<form role="form" class="form-group" action="{{ url_for('.post') }}" method="post">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Ip" name="Ip" type="Ip" autofocus>
</div>
<input name="submit" class="btn btn-default btn-success" type="submit"
value="submit">
</fieldset>
<!-- <input class="from-control" placeholder="ip" name="ip" type="text" value="">
<input name="submit" class="btn btn-default btn-success" type="submit"
value="submit">-->
</form>
@main.route('/post', methods=['GET', 'POST'])
@login_required
def post():
print request.form['Ip']
caseid=Minicomputer.query.filter_by(Ip=request.form['Ip']).first()
print caseid
print caseid.Hostname
form = RepairForm(request.form)
# if request.form["submitpost"] == "submitpost":
if form.validate_on_submit():
# if request.method == "POST":
repair = Repair(Ip=form.ip.data,Series=form.series.data,Hostname=form.hostname.data,
ManagerIp=form.managerip.data,Comp=form.comp.data,
Model=form.model.data,Location=form.location.data,Box=form.box.data,
Important=form.important.data,Faultype=form.faultype.data,
Subject=form.subject.data,Body=form.body.data,Classify=form.classify.data,
Status=form.status.data,auth_id=current_user._get_current_object().id,
Owner=current_user._get_current_object().username,)
db.session.add(repair)
db.session.commit()
flash('报修成功')
return redirect(url_for('.index'))
form.ip.data=caseid.Ip
# form.series.data=caseid.Series
form.hostname.data=caseid.Hostname
# form.managerip.data=caseid.ManagerIp
# form.comp.data=caseid.Comp
# form.model.data=caseid.Model
# form.location.data=caseid.Location
# form.box.data=caseid.Box
# form.important.data=caseid.Important
# form.faultype.data=caseid.Faultype
# form.classify.data=caseid.Classify
# form.status.data=caseid.Status
return render_template('post.html',form=form)
成功获取页面
但是点击提交返回错误,请帮助
The browser (or proxy) sent a request that this server could not understand