Flask - duplicates flash messages

2.1k views Asked by At

I have problem with flask flash() function, get_flashed_messages() always returns me duplicates. I set flash for logout :

@app.route('/logout')
def logout():
    session.pop('logged_in', None)
    flash('You are logged out!', 'success')
    return redirect(url_for('home'))

and in view I have:

{% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
        {% for type, message in messages %}
            <div class="callout {{ type }}">
                {{ message }}
            </div>
        {% endfor %}
    {% endif %}
{% endwith %}

Is it a flask bug? I have printed messages variable and this have more than 1 flash logout message, the count of messages is in range 1-3.

0

There are 0 answers