I have the following views.py file:
from django.contrib import messages
from django.shortcuts import render_to_response
from django.template import RequestContext
def main(request):
messages.set_level(request, messages.DEBUG)
messages.success(request, 'yo')
return render_to_response('main.html',
context_instance=RequestContext(request))
When I use this view, I get the following:
AttributeError at /
'module' object has no attribute 'set_level'
Here is the patch to fix this problem:
Index: contrib/messages/api.py
===================================================================
--- contrib/messages/api.py (revision 12825)
+++ contrib/messages/api.py (working copy)
@@ -4,6 +4,7 @@
__all__ = (
'add_message', 'get_messages',
+ 'get_level', 'set_level',
'debug', 'info', 'success', 'warning', 'error',
)
Yep, as documented here it should made be available.