django middleware: session backed messaging

This basically takes the ideas from the patches on ticket 4604 but puts them into middleware instead of aiming at a modification to core.

DjangoSnippet 1002

I added optional message type passing so you can display them differently.


  • Pingback: Bookmarks about Session

  • Martin

    Thanks for the great work.
    Unfortunatelly I’m failing using yur snippet.
    Creating a message gives me: ‘WSGIRequest’ object has no attribute ‘notifications’ is located in:

    I don’t need to import anything, do I? Any help would be greatly appreciated.

  • Martin

    Here’s my traceback. Put it in Website-field first time

  • Martin

    Sry, for the spamming….
    Problem was, that the folder was not part of my sys.path.
    But still I don’t get any messages in my template :(
    I’m using the exact code of your example, but the if-block is not entered. All I can get is something like

    when I use {{request.notifications}}
    Any advice? :(