1from django.contrib import messages
2
3<--Change setting under settings.py
4from django.contrib.messages import constants as messages
5MESSAGE_TAGS = {
6 messages.ERROR: 'danger'
7}
8-->
9
10{% for message in messages %}
11<div class="alert alert-{{ message.tags }} mb-0 alert-dismissible fade show" role="alert">
12 <strong>Message: </strong> {{ message }}
13 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
14 <span aria-hidden="true">×</span>
15 </button>
16</div>
17{% endfor %}
18
19
20<--Add message
21messages.debug(request, '%s SQL statements were executed.' % count)
22messages.info(request, 'Three credits remain in your account.')
23messages.success(request, 'Profile details updated.')
24messages.warning(request, 'Your account expires in three days.')
25messages.error(request, 'Document deleted.')
26-->
1from django.contrib.messages import constants as messages
2
3MESSAGE_TAGS = {
4 messages.DEBUG: 'alert-info',
5 messages.INFO: 'alert-info',
6 messages.SUCCESS: 'alert-success',
7 messages.WARNING: 'alert-warning',
8 messages.ERROR: 'alert-danger',
9}