Skip to main content

get_flashed_messages

Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the messages are returned, but when with_categories is set to True, the return value will be a list of tuples in the form (category, message) instead.

def get_flashed_messages(
with_categories: bool = False,
category_filter: t.Iterable[str] = ()
) - > list[str] | list[tuple[str, str]]

Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the messages are returned, but when with_categories is set to "True", the return value will be a list of tuples in the form (category, message) instead. Filter the flashed messages to one or more categories by providing those categories in category_filter. This allows rendering categories in separate html blocks. The with_categories and category_filter arguments are distinct: with_categories controls whether categories are returned with message text ("True" gives a tuple, where "False" gives just the message text). category_filter filters the messages down to only those matching the provided categories.

Parameters

NameTypeDescription
with_categoriesbool = FalseSet to "True" to also receive categories along with the message text.
category_filtert.Iterable[str] = ()A filter of categories to limit the returned messages. Only messages belonging to categories present in this iterable will be returned.

Returns

TypeDescription
`list[str]list[tuple[str, str]]`