Rely on message level instead of tag to allow overriding MESSAGE_TAGS #622
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently in base.html, jazzmin compares
message.tagsto hardcoded strings ("success", "error"...) to decide how to display the messages.According to the documentation, "message tags are used as CSS classes to customize message style based on message type":
https://docs.djangoproject.com/en/5.1/ref/contrib/messages/#message-tags
The
MESSAGE_TAGSsetting could be overridden in the global settings.py of a project to handle messages in a specific way in other parts of the project (I mean outside jazzmin).A more reliable way would be to use messages levels that are made available in DEFAULT_MESSAGE_LEVELS:
https://docs.djangoproject.com/en/5.1/ref/contrib/messages/#displaying-messages
This problem was already raised here though the user ended up removing MESSAGE_TAGS from his settings: #344