-1

I hope you can help me, because I can't find an solution on google.

Sense:

If you have logged in, you can switch to the settings otherwise not.

This is my code:

{% if settings is true %}
    <a href="{{ url_for('main.settings') }}" class="navbar-item">
        Settings
    </a>
{% endif %}

This is the Full Code:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Blog</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css" />
    <link rel="stylesheet" href="/css/style.css" />
</head>

<body>
<section class="hero is-fullheight" style="background-color:#C4FCEF;">

    <div class="hero-head">
        <nav class="navbar">
            <div class="container">

                <div id="navbarMenuHeroA" class="navbar-menu">
                    <div class="navbar-end">
                        <a href="{{ url_for('main.index') }}" class="navbar-item">
                            Home
                        </a>
                        {% if current_user.is_authenticated %}
                        <a href="{{ url_for('main.profile') }}" class="navbar-item">
                            Profile
                        </a>
                        {% endif %}

                        {% if settings == true %}
                        <a href="{{ url_for('main.settings') }}" class="navbar-item">
                            Settings
                        </a>
                        {% endif %}

                        {% if not current_user.is_authenticated %}
                        <a href="{{ url_for('auth.login') }}" class="navbar-item">
                            Login
                        </a>
                        <a href="{{ url_for('auth.signup') }}" class="navbar-item">
                            Sign Up
                        </a>
                        {% endif %}
                        {% if current_user.is_authenticated %}
                        <a href="{{ url_for('auth.logout') }}" class="navbar-item">
                            Logout
                        </a>
                        {% endif %}
                    </div>
                </div>
            </div>
        </nav>
    </div>

    <div class="hero-body">
        <div class="container has-text-centered">
            {% block content %}{% endblock %}
        </div>
    </div>
</section>
</body>

</html>

This is the Error:

TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

Error:

ARCOON
  • 19
  • 5

1 Answers1

0

Try changing {% if settings is true %} to {% if settings %} or {% if settings == true %} or {% if settings is sameas true %}

Refer here

Kishore Sampath
  • 973
  • 6
  • 13