[Solved]-Does Bootstrap/Django Error message has no red color?

20👍

The issue is that Django’s default message tags do not match perfectly with Bootstrap’s contextual classes. Bootstrap uses the contextual class danger for the color red. You can add the MESSAGE_TAGS setting to your settings.py to apply the danger tag to messages with the level messages.ERROR.

To change the default tags for a message level (either built-in or custom), set the MESSAGE_TAGS setting to a dictionary containing the levels you wish to change. As this extends the default tags, you only need to provide tags for the levels you wish to override:

settings.py

from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
    messages.ERROR: 'danger',
}

Leave a comment