the old bootstrap2 had a 1-1 mapping with django messages, so you could write:
class= {{message.tags }}-alert
Now 'error' changed to 'danger' in bs3, so any way this app can compensate for that? I added it manually. Is that the best way to handle that or could you squeeze this in to this app?
{% for message in messages %}
<div{% if message.tags %} class="alert alert-{{ message.tags }} {% if message.tags = 'error' %}alert-danger{%endif%}"{% endif %}>
<button type="button" class="close" data-dismiss="alert">×</button>
{{ message|safe }}
</div>
{% endfor %}
In your django settings add the following:
# needed to make this work with bootstrap labels
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
This is for sure a lot cleaner, thanks!
This seems like the best way.
I think this one has to be reopened. If you override in MESSAGE_TAGS
the level id displayed wrong in the admin panel. Furthermore, you should use message.level_tag
instead of message.tags
because message.tags
could be 'customtag warning'
.
Most helpful comment
In your django settings add the following: