The Django Messages Framework Application

By: Dusty Arlia
Published on Saturday, February 1, 2014, 12:32 PM
Last Updated on Tuesday, July 07, 2015 at 10:24 PM
Total Updates: 2

The Django messages framework is an application that is used to temporarily store messages in one request and retrieve them for display in a subsequent request. Every message is tagged with a specific level that determines its priority. The built-in levels are: debug (Development-related messages that will be ignored (or removed) in a production deployment), info (informational messages for the end-user), success (e.g. “Your checkout was successful”), warning (a failure did not occur but may be imminent), and error (a failure occurred). These can be imported from django.contrib.messages. Message levels allow you to group messages by type so they can be filtered or displayed differently in views and templates. The messages framework can use different backends to store temporary messages.

The MESSAGE_LEVEL setting can be used to change the minimum recorded level (or it can be changed per request). Attempts to add messages of a level less than this will be ignored.