I have a view in which I send some messages, like this:
messages.warning(request, 'Nothing found")
In my settings.py
I have edited the message tags like:
MESSAGE_TAGS = {
messages.DEBUG: 'alert-info',
messages.INFO: 'alert-info',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger'
}
on my template, I display them like this:
{% for message in messages %}
<div class="alert {{ message.tags }} alert-dismissible fade in">
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{% if message.tags == 'info' %}
<p>{{ message }}<br>
You have <strong>{{users}}</strong> user{{users|pluralize}}<br>
,around <strong>{{non_users}}</strong> non user{{non_users|pluralize}}</p>
{% else %}
<p>{{ message }}</p>
{% endif %}
</div>
{% endfor %}
When the template loads, the messages appears very fast and disappears.
If I try this: <p>{{message}}</p>
instead the message stays there, so I'm guessing I'm doing something wrong with bootstrap.
This (kinda) works as well: <div class="{{message.tags}}">
Could someone shed a light?
Edit:
I just noticed this is happening specifically when I use messages.error()
, the rest of them are working properly, can't seem to find what's wrong.