pythondjangodjango-viewsweb2pyflash-message

Showing flash messages in DJango with close button


I want to display flash messages in Django with the close button. Existing message framework in Django allows to display messages and does not allow to close it.

As an example, web2py provides such flash messages. I am looking for similar functionality in Django.

Flash Message in web2py

If it can be done with few lines of code , it would be great. I do not want to add any other libraries or framework on top of Django.

Thanks in advance.


Solution

  • I was unaware that such thing can be solved using boot-strap !

    I did something like this :

    {% if messages %}
      {% for msg in messages %}
        <div class="alert alert-info alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          {{msg.message}}
        </div>
      {% endfor %}
    {% endif %}
    

    It shows message like : Flash Message in Django