[英]python flask: append to form if request.method == 'POST'
我有一個 html 表單,在發布時,我可以將表單傳遞給 mongodb
if request.method == 'POST':
new_employee.insert_one(request.form.to_dict())
這有效......但是當表單發布時你將如何附加額外的字符串
例如
if request.method == 'POST':
employee_username = (request.form['employee_first_name'] + '.' + request.form['employee_last_name'])
new_employee.insert_one(request.form.to_dict())
您將如何附加例如“employee_username”:employee_username
試試這個:
if request.method == 'POST':
post_data = request.form.to_dict()
employee_username = (request.form['employee_first_name'] + '.' + request.form['employee_last_name'])
post_data['employee_username'] = employee_username
new_employee.insert_one(post_data)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.