Skip to content

Customization of message-to-alert mapping #241

Open
@greyhare

Description

@greyhare

In bootstrap4/templatetags/bootstrap4.py, there's a function bootstrap_message_classes which figures out what classes to assign to a Bootstrap Alert generated from a Django message. Right now, it makes the obvious mappings, except for two:

  • message_constants.DEBUG is mapped to alert-warning, and
  • messages without a proper level set get alert-danger.

Personally, I'd like DEBUG mapped to alert-secondary (gray background) and the default to be alert-primary (darker blue background) because I don't want things that aren't warnings or errors to look like them. Others might want to use alert-light or alert-dark. But there's no obvious way to change this. Monkeypatching the function might not work because @register.filter would still register the old one. Maybe I could alter MESSAGE_LEVEL_CLASSES, but is that the right way?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions