Messages

Introduction

Websauna supports a message flashing. There are pop up notifications on the top of the page, usually shown to the user after the user did something and was HTTP redirected to another page.

Flash messages are stored in the user session storage which is in Redis by default.

Usage

Flashing a plain text message to a logged in user:

from websauna.system.core import messages

def my_view(request):

    # msg_id is passed as CSS id and is useful in functional testing
    messages.add(request, kind="info", msg="Hello world!", msg_id="msg-hello-world")

For an HTML message example please see nag tween example.

For advanced usage see websauna.system.core.messages.add().

Rendering

Flash messages are rendered by site/messages.html. After rendering the flash message queue is cleared.