亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Flask 將 request.form 值傳遞給 url_for

Flask 將 request.form 值傳遞給 url_for

飲歌長嘯 2021-06-11 22:08:32
我有一個 Flask 模板,它顯示一個頁面,其中包含一個dropdown列表owners,一個table包含所有者的輸贏記錄,以及一個radio在regular賽季記錄和playoff記錄之間切換的頁面。所需的工作流程是:如果通過導航欄導航到頁面,它應該默認為/matchup-history/regular。(這有效)否則,無論何時radio切換,它都應該相應地路由。(這不起作用)比賽歷史.html{%- extends "base.html" -%}{% block nav_matchups %}active{% endblock %}{%- block content -%}  <form action="{{ url_for('show_matchup_history', matchup_type=request.form['matchup_type']) }}" method="post">    <label>      <select name="owner_id" onchange="this.form.submit()">      {%- for o in owners %}        {%- if request.form['owner_id'] == o['owner_id']|string() %}        <option value="{{ o['owner_id'] }}" selected>{{o['first_name'] + " " + o['last_name'] }}</option>        {%- else %}        <option value="{{ o['owner_id'] }}">{{o['first_name'] + " " + o['last_name'] }}</option>        {%- endif %}      {%- endfor %}      </select>    </label>    {% block matchup_type_radio %}{% endblock %}  </form>  {%- if records|length > 0 %}  <div class="stats-table">    <table>      <tr>        {%- for th in table_headers %}        <th>{{ th }}</th>        {%- endfor %}      </tr>      {%- for r in records %}      <tr>        {%- for cn in column_names %}        <td>{{ r[cn] }}</td>        {%- endfor %}      </tr>      {%- endfor %}    </table>  </div>  {%- endif %}{% endblock -%}比賽歷史/regular.html{%- extends "matchup-history.html" -%}{% block matchup_type_radio %}<label><input type="radio" name="matchup_type" value="regular" onclick="this.form.submit()" checked>Regular Season</label><label><input type="radio" name="matchup_type" value="playoffs" onclick="this.form.submit()">Playoffs</label>{% endblock %}比賽歷史/playoffs.html{%- extends "matchup-history.html" -%}{% block matchup_type_radio %}<label><input type="radio" name="matchup_type" value="regular" onclick="this.form.submit()">Regular Season</label><label><input type="radio" name="matchup_type" value="playoffs" onclick="this.form.submit()" checked>Playoffs</label>{% endblock %}
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 279 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號