By default, messages.success outputs class='success'. Either I need to rewrite this, or delete it, or add tags to it to meet my needs. I could not find a way to rewrite and add to it. Here I tried to use extra_tags...
views.py
messages.success(request, '<a href="#">Item</a> Saved', extra_tags='html_safe alert alert-')
detail.html
I tried adding alertbefore {{ message.tags }}.
{% if messages %}
<ul class='messages'>
{% for message in messages %}
<li{% if message.tags %} class='{{ message.tags }}' role='alert'{% endif %}>{% if 'html_safe' in message.tags %}{{ message|safe }}{% else %}{{ message }}{% endif %}</li>
{% endfor %}
</ul>
{% endif %}
Download Alerts Pending class='alert alert-success'
<div class="alert alert-success" role="alert">
<strong>Well done!</strong> You successfully read this important alert message.
</div>
The result of the original HTML page
When all of the above code is executed, the source code outputs the following. The only problem now is the gap between alert-and success.
<ul class='messages'>
<li class='html_safe alert alert- success' role='alert'><a href="#">Item</a> Saved</li>
</ul>
The end of the goal! - Can anyone see a hacker or the right workaround here?
<li class="html_safe alert alert-success" role="alert"><a href="#">Item</a> Saved</li>