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 trialAbdirahman Mohamed
84 PointsI did everything in Pycharm and I got this error: jinja2.TemplateSyntaxError: unkown field render_template.
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'render_field'.
Abdirahman Mohamed
84 PointsHere 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
Treehouse Moderator 68,454 PointsAre the spaces in your syntax causing the import to fail?
Replace "{ %" with "{%"
Abdirahman Mohamed
84 PointsIt didn't work :(
Abdirahman Mohamed
84 PointsThank you so much it worked :)
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsIn 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.
Chris Freeman
Treehouse Moderator 68,454 PointsMoved comment to answer
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsCan you include your template code?