我的 POST 发送所选 RadioField 的数据,但在 Flask 中,我只为form.display.data
. GET 工作正常,并且 RadioFields 在页面上,当我单击“提交”时,显示变量将在 POST 中发送并带有正确的选择。
如何获取 POST 的实际数据?
视图.py
class Items(SimpleFormView):
route_base = "/manage"
datamodel = SQLAInterface(TerminalA82)
message = "Please make a seslection"
form = List_Items()
myList = Controller.generate #<-- external function provides list
form.display.choices = myList
@expose('/manage', methods=['GET'])
@has_access
def this_form_get(self):
return self.render_template('list_items.html', param1='Items', form=self.form)
@expose('/manage', methods=['POST'])
@has_access
def this_form_post(self):
return self.render_template('blank.html', param1=str(self.form.display.data))
POST 在页面上呈现“无”。
表格.py
class List_Items(Form):
display = RadioField('Items', choices=[], coerce=int)
list_items.html(模板)
{% extends "appbuilder/base.html" %}
{% block content %}
<h3>{{param1}}</h3>
<form method="post">
{{ form.display }}
<input type="submit" value="Submit">
</form>
{% endblock %}
我的列表内容
>>> print myList
[('5', 'MyBAsic'), ('9', 'Cloudtest'), ('12', 'Test2'), ('15', 'NHLS-Test'), ('18', 'HSRC-Test')]
>>>
空白.html
{% extends "appbuilder/base.html" %}
{% block content %}
<p>{{param1}}</p>
{% endblock %}