Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Nursultan Bolatbayev16,774 Points
What is advantage of form.as_p?
What is advantage of applying form.as_p instead of just form? I know that it will put each label and input into separate p. But why? Just for style selector or any other benefits?
Chris FreemanTreehouse Moderator 67,464 Points
You are correct that
form.as_p simply wraps all the elements in HTML
<p> tags. The advantage is not having to write a loop in the template to explicitly add HTML to surround each title and field.
There is also
form.as_ul to also help set the form within the HTML context you wish. More details in Django form rendering options docs.