我的 app.py 看起来像这样:from flask import Flask,render_template,url_for,requestfrom flask_bootstrap import Bootstrapfrom wtforms import SelectFieldfrom flask_wtf import FlaskFormapp = Flask(__name__)Bootstrap(app)def Form(FlaskForm): panel_brand = SelectField('Panel Brand',choices=[('tr','trina'),('lo','longi'), ('ph','phono'), ('leap','leapton')]) mounting = SelectField('Mounting',choices=[('tr','trina'),('lo','longi'), ('ph','phono'), ('leap','leapton')]) inverter = SelectField('inverter',choices=[('Fronius10','Fronius 10'),('Fronius5','Fronius 5'), ('huawei6','huawei 6'), ('huawei8','huawei 8') , ('SolarEdge125','SolarEdge 12,5')]) order_fulfillment = SelectField('orderfulfillment',choices=[('all3','Panels + inverter + mounting'),('Panels','Panels'),('panelsinv','Panels + Inverter'),('installer','By Installer')])@app.route('/', methods=['GET','POST'])def index(): form = Form(FlaskForm) return render_template('index.html', form=form)if __name__ == '__main__': app.run(debug=True)我的索引.html看起来像这样<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title></head><body> <form method="POST"> {{ form.csrf_token }} {{ form.panel_brand }} {{ form.mounting }} {{ form.inverter }} {{ form.order_fulfillment }} <input type="submit"> </form></body></html>当我运行 app.py 文件时,它只显示提交按钮,而不是预期的下拉列表,,,, - 具有后续值。我想我在函数中缺少一些调用ID?我不确定如何以正确的语法做到这一点。任何人都可以帮我吗?panel_brandmountinginverterorder_fulfillmentindex()
添加回答
举报
0/150
提交
取消