Skip to main content

Message

Represent an actual message that can be stored in any of the supported storage classes (typically session- or cookie-based) and rendered in a view or template.

Attributes

AttributeTypeDescription
levelintInteger representing the severity level of the message, used to categorize and filter messages.
messagestringThe actual text content of the message to be rendered in a view or template.
extra_tagsstringAn optional string of custom CSS classes or identifiers to be applied to the message for styling or categorization.
tagsstringA space-separated string combining the level-specific tag and any extra tags for use in HTML class attributes.
level_tagstringThe string representation of the message level retrieved from the global LEVEL_TAGS mapping.

Constructor

Signature

def Message(
level: int,
message: str,
extra_tags: str = None
)

Parameters

NameTypeDescription
levelintThe severity level of the message (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL).
messagestrThe actual content of the message.
extra_tagsstr = NoneAn optional string of custom tags to associate with the message.

Methods


tags()

@classmethod
def tags() - > string

Combines the message's level tag and any extra tags into a single space-separated string.

Returns

TypeDescription
stringA space-delimited string of all CSS classes or tags associated with the message.

level_tag()

@classmethod
def level_tag() - > string

Retrieves the string label corresponding to the message's numerical importance level.

Returns

TypeDescription
stringThe string representation of the message level, or an empty string if the level is not recognized.