Skip to main content

CheckMessage

This class represents a message generated by the system check framework, encapsulating details such as severity level, a descriptive message, an optional hint, and the related object. It provides functionality to determine if a message is serious enough to halt operations or if it has been silenced via configuration. The class also includes a formatted string representation for clear reporting of check results.

Attributes

AttributeTypeDescription
levelintAn integer representing the severity of the check message used to determine if the issue is serious enough to halt operations.
msgstringA string containing the primary description of the issue or informative message being reported.
hintstring = NoneAn optional string providing actionable advice or a suggested fix to resolve the reported issue.
objobject = NoneThe specific object, such as a model or field, that is the source of the check message.
idstring = NoneA unique identifier string for the check, used to categorize the message and allow for silencing specific checks via settings.

Constructor

Signature

def CheckMessage(
level: int,
msg: str,
hint: str = None,
obj: object,
id: str = None
) - > null

Parameters

NameTypeDescription
levelintThe severity level of the check message.
msgstrThe main message text.
hintstr = NoneAn optional hint providing more details on how to fix the issue.
objobjectThe object that caused the message to be generated. Defaults to None.
idstr = NoneA unique identifier for the check message.

Methods


is_serious()

@classmethod
def is_serious(
level: integer = ERROR
) - > boolean

Checks if the message's severity level meets or exceeds a specified threshold.

Parameters

NameTypeDescription
levelinteger = ERRORThe severity threshold to compare against the message's current level.

Returns

TypeDescription
booleanTrue if the message level is greater than or equal to the provided threshold level.

is_silenced()

@classmethod
def is_silenced() - > boolean

Determines whether the message should be suppressed based on the project's SILENCED_SYSTEM_CHECKS setting.

Returns

TypeDescription
booleanTrue if the message's ID is present in the silenced checks configuration, False otherwise.