gpt4 book ai didi

twitter-bootstrap-3 - 模板语法错误 : invalid syntax for function call expression

转载 作者:行者123 更新时间:2023-12-03 17:33:00 25 4
gpt4 key购买 nike

我尝试将 flask-wtf 与下面的 bootstrap-select 结合使用,但我修改了 TemplateSyntaxError: invalid syntax for function call expression

<form class="form-inline" action="/" method="POST" role="form">
<div class="input-group">
{{ form.hidden_tag() }}
<span class="input-group-addon">Make:</span>
{{ form.make(id="make_select", class="selectpicker form-control", data-live-search="true") }}
<span class="input-group-addon">Model:</span>
{{ form.model(id="model_select", class="selectpicker form-control", data-live-search="true") }}

<span class="input-group-btn">
<button class="btn btn-default" type="submit">Search!</button>
</span>
</div>
</form>

.
TemplateSyntaxError: invalid syntax for function call expression
Traceback (most recent call last):
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/mic/projects/unisnpdb/main.py", line 58, in decorated_function
body = render_template(template_name, **ctx)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/flask/templating.py", line 127, in render_template
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/environment.py", line 830, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/environment.py", line 791, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/environment.py", line 765, in _load_template
template = self.loader.load(self, name, globals)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/environment.py", line 554, in compile
self.handle_exception(exc_info, source_hint=source)
File "/home/mic/.virtualenvs/unisnp/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mic/projects/unisnpdb/templates/search_page.tmpl", line 66, in template
{{ form.make(id="make_select", class="selectpicker form-control", data-live-search="true") }}
TemplateSyntaxError: invalid syntax for function call expression

.
from flask.ext.wtf import Form
from wtforms import SelectField


class VehicleForm(Form):
make = SelectField(u'', choices=())
model = SelectField(u'', choices=())

为什么 data-live-search"="true"导致 TemplateSyntaxError?

最佳答案

看看这个片段:http://flask.pocoo.org/snippets/107/

在你的情况下更换:

{{ form.make(id="make_select", class="selectpicker form-control", data-live-search="true") }}

经过
{{ form.make(id="make_select", class="selectpicker form-control", **{'data-live-search':'true'}) }}

关于twitter-bootstrap-3 - 模板语法错误 : invalid syntax for function call expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26172246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com