Messages

Django Messages Framework and Custom Tags by Eric on February 1, 2020

![null](/img/screenshot-from-2013-08-22-090436-300x144.png) Sometimes it's necessary to display a message to the user in a quiet and clean manner.  To do this, Django has given us the messages framework for cookie- and session-based messaging.  After a form or other input is submitted we can quickly send a short message to the user without much effort at all.  Here are all the documents related to the framework but I'm going to give you the quick version as well as some customization options and Bootstrap fixes. The messaging framework is enabled by default when you create a new Django project so good job you're half way there!  Now just add this bit of code to the top of any page you want messages to appear:{% if messages %} <ul> {% for message in messages %} <li{% if message.tags %}{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} We have this in our base that is inherited by every page to allow the functionality to appear on the entire site.  You need t...