烧瓶是否修剪 项目?

问题描述 投票:0回答:1

[在Flask中并使用Jinja2,我正在调用数据列表,但由于某种原因,任何带有空格的选项都被剪裁了,因此“西红柿酱”变成了“西红柿”。这是Flask正在做的事情,还是我弄乱了模板?

<!-- HOMEPAGE -->
<form type="text" id="homeForm" class="centered" method="post" onsubmit="return false;">
        {{ form.hidden_tag() }}
        <input type="text" id="homeInput" autocomplete=off list="topps" placeholder="Input here">
        <datalist id="topps">
            {% for top in topps %}
            <option value={{ top }}>
            {% endfor %}
        </datalist>
        <button type="submit" id="homeSubmit">Submit</button>
</form>

# ROUTES.PY #
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index():
    form = ToppingsForm()
    topps = ["tomato sauce", "chilli flakes","something else"]
    return render_template('index.html', title='Home', form=form, topps=topps)
html flask jinja2 flask-wtforms datalist
1个回答
0
投票

您的问题在这里:

<option value={{ top }}>

{{top}}之外添加引号

<option value="{{ top }}" />
© www.soinside.com 2019 - 2024. All rights reserved.