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 A Social Network with Flask Broadcasting Add Some Layout

justlevy
justlevy
6,325 Points

{% if current_user.is_authenticated %}

To save someone time, be sure to turn off 'Browser Cookie Blockers' or 'Brave Shields' or anything similar.

I was having trouble setting {% if current_user.is_authenticated %} to True to show the username on the webpage.

Hope this helps someone!

This is relevant to this code in layouts.html:

<div class="grid-33">
<!-- Say Hi -->

<h1>Hello{% if current_user.is_authenticated %} {{ current_user.username }} {% endif %}</h1>

</div>

            <div class="grid-33">

                <!-- Log in/Log out -->
                {% if current_user.is_authenticated %}
                <a href="{{ url_for('logout') }}" class="icon-power" title="Log out">Log Out</a>
                {% else %}
                <a href="{{ url_for('login') }}" class="icon-power" title="Log in">Log In</a>
                <a href="{{ url_for('register') }}" class="icon-profile" title="Register">Register</a>
                {% endif %}
            </div>

          </div>

        </header>

1 Answer