vieviews.py
messages.success(request, 'You are now logged out')
settings.py
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'error'
}
alert. html - используется bootstrap
{% if messages %}
{% for message in messages %}
< div id="message" class="container-fluid animated fadeInUp" style="position:absolute; z-index:1000; top:32%;">
< div class="row text-center">
< div class="ml-auto mr-2 col-4 alert alert-{{ message.tags }} alert-dismissible text-center" role="alert">
< button type="button" class="close" data-dismiss="alert">< span aria-hidden="true">×</span>.
</button>
< strong>
{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}
Error:
{% else %}
{{ message.tags|title }}
{% endif %}
</strong>
{{ message }}
</div>
</div>
</div>
{% endfor %}
{% endif %}
base. html
{% include 'alert.html' %}