def get_and_delete_messages(request, include_auth=False):
 assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
 messages = request.session.pop('messages', [])
 if (include_auth and request.user.is_authenticated()):
  messages.extend(request.user.get_and_delete_messages())
 return messages

def get_and_delete_messages ( request , include_auth = False ) : assert hasattr ( request , 'session' ) , "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." messages = request . session . pop ( 'messages' , [ ] ) if ( include_auth and request . user . is_authenticated ( ) ) : messages . extend ( request . user . get_and_delete_messages ( ) ) return messages
get and delete all messages for current session .