我正在做一个小项目-提醒系统。我有一个可以接受用户值并将其插入数据库表的表单。从文本框中获取值时发生问题。下面是我的代码,我也给出了错误提示。
<form method="POST" action="">
<input type="hidden" name="unique" value="{{session.UID}}" disabled="true">
<button type="submit" class="btn btn-primary">Confirm</button>
</form>
这是我的模板
@app.route('/home/set_reminder',methods=['POST'])
@is_logged_in
def set_reminder():
if request.method=='POST' and form.validate():
uid = request.form['unique']
此行uid = request.form['unique']
中出现错误。无法理解为什么它无法获取值。
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'unique'
这是正在得到的错误。 请帮帮我。