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

Matthew Shipman
Matthew Shipman
11,369 Points

iterating through the field in form results in an extra HTML tag

using the code exactly as its presented in the video, I'm running into a problem while iterating through the form. I think the problem is in the block of code below.

{% from 'macros.html' import render_field %} <form method="POST" action="" class="form"> {{ form.hidden_tag() }} {% for field in form %} {{ render_field(field) }} {% endfor %} <button type="submit" id="submit">Register!</button> </form>

If you check the element inspector in the browser, an extra (blank) field is created after all the form fields are iterated through and created. Its as if the for loop is executing one final time inexplicably. You cant see it in the browser rending because there's no formatting but if you try to add any CSS the problem becomes apparent. Whats going on here? Why is render_field() executing one extra time?