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 Django Basics Final Details Content Field

nicole lumpkin
PLUS
nicole lumpkin
Courses Plus Student 5,328 Points

Django filter 'linebreaks' didn't produce the same pattern of html tags as Kenneth's.

This is my code from learning_site>courses>views.py. The linebreaks filter should seemingly produce <p> tags around each line in the content field.

{% extends "layout.html" %}

{% block title%}{{step.title}}-{{step.course.title}}{% endblock %}
{% block content%}
<article>
    <h2>{{step.course.title}}</h2>
    <h3>{{step.title}}</h3>
    {{step.content|linebreaks}}
</article>
{% endblock %}

However, when I highlighted 'Python' in the browser just as Kenneth did, then right-clicked and selected 'Inspect', my html looked quite different from his. Namely, the presence of the <br> tags

<p>
    "Launch the shell with Python"
    <br>
    "You can exit the shell using "exit()" or "quit()"
    <br>
    "You can also exit the shell by pressing CTRL + d
</p>

Can anyone shed some light on these differences?

1 Answer

Haydar Al-Rikabi
Haydar Al-Rikabi
5,971 Points

Two enter hits on the keyboard are rendered as <p> tag, while one enter hit is rendered as <br>.

nicole lumpkin
nicole lumpkin
Courses Plus Student 5,328 Points

Thanks so much Haydar Al-Rikabi ! It's fun but hard learning all this by yourself! Your feedback is truly appreciated :)