WTFormsを使用すると、SQLAlchemyユーザーに国キーワードを選択させようとしています。その選択肢から、(西、南、東、北)の座標を渡します。その国をプログラムに戻してください。ユーザーの選択に基づいて列から値を取得する
choices=GeoKeywords.label
が国を上手く通過するため、これがどのように行われるかについては固まっています。 「アルバニア」を選択すると値「アルバニア」が渡されます。しかし、その選択に基づいて西、南、東、北をどのように持ち込むことができますか?
データベース表:
GP_DD_GEOKEYWORDS= Table('GP_DD_GEOKEYWORDS', Base.metadata,
Column('VALUE', String(75)),
Column('LABEL', String(75)),
Column('WEST', String(50)),
Column('SOUTH', String(50)),
Column('NORTH', String(50)),
Column('EAST', String(50)))
class GeoKeywords():
s = select([GP_DD_GEOKEYWORDS.c.VALUE, GP_DD_GEOKEYWORDS.c.LABEL])
result = connection.execute(s)
label = [row for row in result]
class ReusableForm(Form):
region = SelectField('Geographic Keyword:', choices=GeoKeywords.label)
@app.route("/editorother", methods=['GET', 'POST'])
@login_required
def editorother():
form = ReusableForm(request.form)
if request.method == 'POST':
region = request.form['region']
if form.validate():
"Do stuff with region and coordinates"
私はこれをどのように実装することができますか? – Infinity8