how to show message alert in django template
step1: in views.py------> from django.contrib import messages
step2: in views.py--------> inside function you created for a particular task; i.e . if you want to submit form and want message " your form is successfully authorized"
then inside function before : return redirect(auth.html) write : message. message_type(request,'your form is successfully authorized')
step3: if you want to redirect that page to auth.html then go to auth.html and
{% block body%}
{% for message in messages %}
<div class="alert alert-{{message.tags}} alert-dismissible fade show" role="alert">
<strong>helo!</strong> {{message}}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>{% end for%}
{% endblock body%}
Comments
Post a Comment