Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Takin' Names Macros

I did everything in Pycharm and I got this error: jinja2.TemplateSyntaxError: unkown field render_template.

jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'render_field'.

Here is my code for register.html

{ % from 'macros.html' import render_field %}

<form method="POST" action="" class="form">
    {{ form.hidden_tag() }}
    { % for field in form %}
          {% render_field(field) %}
    { % endfor %}

</form>

here is my macros.html

{% macro render_field(field) %}
        <div class="field">
            {% if field.error %}
                {% for error in field.erros %}
                    <div class="notification error">{{ error}} </div>
                {% endfor %}
            {% endif %}
            {{ field(placeholder= field.label.text) }}
        </div>
{% endmacro %}
Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Are the spaces in your syntax causing the import to fail?

Replace "{ %" with "{%"

It didn't work :(

Thank you so much it worked :)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

In the video, it looks like statement delimiters are used {{ render_field(field) }} instead of expression delimiters {% render_field(field) %}. See video at time 1:21.