当点击图片时,将jinja2中的列表条目链接并重定向到路线



我正在尝试将图像重定向到位置为x[1]的列表中具有userid(user(的页面。我不能使用{{x[1]}}来传递用户吗?

<a href="{{ url_for('getprofile'), user= {{ x[1] }})">
<img class="img-responsive" src=" {{x[0]}}" >
</a>

我得到错误:

<a href="{{ url_for('getprofile'), user= {{ x[1] }})">
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got '='

我在这里做错了什么?

使用不带额外{{ }}的变量。

<a href="{{ url_for('getprofile', user=x[1]) }}">
<img class="img-responsive" src="{{ x[0] }}">
</a>

最新更新