使用Python从postgresql数据库中获取的数据填充html下拉列表
看来你需要读一下Flask的书来学习一些基础知识 这是一个满足您需求的最小应用程序 查看功能: 模板/index.html使用Python从postgresql数据库中获取的数据填充html下拉列表,html,forms,postgresql,flask,drop-down-menu,Html,Forms,Postgresql,Flask,Drop Down Menu,看来你需要读一下Flask的书来学习一些基础知识 这是一个满足您需求的最小应用程序 查看功能: 模板/index.html {items%%中的项的%s} {{item.field_name} {%endfor%} 这实际上与上述发布相反,我需要数据库(postgresql)中的数据以选择html形式发布,不是使用php,而是使用python flaskAh gotcha,标志已删除! <html> <head> </head> <body&g
{items%%中的项的%s}
{{item.field_name}
{%endfor%}
这实际上与上述发布相反,我需要数据库(postgresql)中的数据以选择html形式发布,不是使用php,而是使用python flaskAh gotcha,标志已删除!
<html>
<head>
</head>
<body>
<form>
<select multiple="multiple"
<option value="Hello">Hello</option>
</select>
</form>
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
items = get_your_data_from_db()
return render_template('index.html', items=items)
<html>
<head>
</head>
<body>
<form>
<select multiple="multiple">
{% for item in items %}
<option value="{{ item.field_name }}">{{ item.field_name }}</option>
{% endfor %}
</select>
</form>
</body>
</html>