Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#13170 closed (fixed)

messages set_level AttributeError

Reported by: dm Owned by: nobody
Component: Contrib apps Version: master
Severity: Keywords: messages, set_level, get_level
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I have the following 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',

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/
--- contrib/messages/     (revision 12825)
+++ contrib/messages/     (working copy)
@@ -4,6 +4,7 @@
 __all__ = (
     'add_message', 'get_messages',
+    'get_level', 'set_level',
     'debug', 'info', 'success', 'warning', 'error',

Attachments (1)

ticket_13170.diff (1.0 KB) - added by Tobias McNulty 7 years ago.
patch that adds get_level & set_level to all

Download all attachments as: .zip

Change History (6)

comment:1 Changed 7 years ago by Chris Beaven

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Yep, as documented here it should made be available.

comment:2 Changed 7 years ago by Tobias McNulty

Owner: changed from nobody to Tobias McNulty
Status: newassigned

Changed 7 years ago by Tobias McNulty

Attachment: ticket_13170.diff added

patch that adds get_level & set_level to all

comment:3 Changed 7 years ago by Tobias McNulty

Owner: changed from Tobias McNulty to nobody
Status: assignednew
Triage Stage: AcceptedReady for checkin

comment:4 Changed 7 years ago by Karen Tracey

Resolution: fixed
Status: newclosed

(In [12826]) Fixed #13170: Make get_level and set_level importable from django.contrib.messages,
as documented. Thanks dm, SmileyChris, tobias.

comment:5 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top