python flask Dynami c Параметр раскрывающегося списка выбран в шаблоне1, чтобы остаться в шаблоне2. temp2 наследуется от temp1 - PullRequest
0 голосов
/ 17 февраля 2020
@app.route('/small', methods=['GET', 'POST', 'PUT'])
def small_main():
    """Small Main page"""
    if request.method == 'POST' or request.method == 'GET' or request.method == 'PUT':
        l_sites = basic_operations.display_sites()
        site_choices = [(str(x), l_sites[x]) for x in range(0, len(l_sites))]
        selected = request.args.get('site_choice', 'Small site')
        site = {'site_choice': selected}
        return render_template('small.jinja2', site_choices=site_choices, site=site)

@app.route('/dns/', methods=['GET', 'POST', 'PUT'])
def cfd():
    cfd_content = "Place holder for CFD content"
    return render_template('cfd.jinja2', CFD_Content=cfd_content, site=request.form.get('sites'))

{% extends 'small.jinja2' %}
{{ super() }}
<form method="POST">
{% block content %}
    {{ CFD_Content }}
</form>
{% endblock content %}

В первом шаблоне есть раскрывающийся список, однако, когда я вызываю вторую функцию маршрута, я не могу сохранить выбор из первого маршрута. Каков наилучший способ сохранить выбранное значение от первого шаблона до второго шаблона.

...