M
M
Mansur052020-04-16 13:25:47
Bootstrap
Mansur05, 2020-04-16 13:25:47

How to activate Bootstrap 4 notification?

bootstrap has notifications .

How to activate such a notification? The documentation only says how to close it.

Scenario: The user entered data, clicked on the button. The data has been checked and if it is invalid, a notification is called.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
organica, 2020-04-16
@organica

views:

from django.contrib import messages
        if user is not None:
            login(request, user)
            messages.success(request, 'Вход выполнен')
        else:
            messages.error(request, "Неправильный логин")

Templates/AppName/Messages.html:
{% for message in messages %}
  <div class="alert {{ message.tags }} alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
    {{ message }} {{ user.first_name}} {{ user.last_name}}
  </div>
{% endfor %}

Required_template.html:
<div class="col-md-4">
        {% include 'AppName/messages.html' %}
    </div>

S
smigles, 2020-04-16
@smigles

You can initially prescribe the class d-nonefor the alert so that the alert is not displayed, and then, when you need to display the alert, remove this class:
$('#alert').removeClass('d-none');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question