Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jinja variables within the Flask url_for function [duplicate]

I have tried multiple different things, but cannot get the URL to appear as /item like I want it to. I know that everything else is functioning correctly because if I simply replace {{item}} with a string, it works fine. Am I missing something here?

Here is the code section where the problem lies:

<div class="person_images_group">
    {% for item in names %}
        <div class="personlist">
            <a href={{ url_for('name', name = {{item}} ) }}>
                <img id={{ item }} src="" alt={{ item }} width="40" height="40">
            </a>
        </div>
        <script>
            document.getElementById("{{ item }}").src = getName("{{ item }}");
        </script>
    {% endfor %}
<div>

Thank you

like image 302
Excuse.my.stupidity Avatar asked Jun 02 '14 06:06

Excuse.my.stupidity


1 Answers

You try use {{}} in {{}} block. So right usage is {{ url_for('name', name=item) }}.

like image 131
tbicr Avatar answered Oct 16 '22 09:10

tbicr