I am using Django's messages framework to indicate successful actions and failed actions.
How can I exclude account sign in and sign out messages? Currently, landing on a page after signing in displays
Successfully signed in as 'username'
. I do not want this message to be displayed, but all other success messages should be displayed. What I attempted is shown below. I tried using logic to find if the message had the word "signed"
in it. If it did, do not display it. That however is not working though.
{% if messages %}
<div class="db-section">
<ul class="messages">
{% for message in messages %}
{% if "signed" in message %}
# Don't display anything
{% else %}
<div class="alert alert-error">
<strong style="color:{% if 'success' in message.tags %}green{% else %} red {% endif %};padding-bottom:10px;">{{ message }}</strong>
</div>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
Could someone possibly explain why the above code is still displaying messages that even contain "signed"
in it?