Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#13170 closed (fixed)

messages set_level AttributeError

Reported by: dm Owned by: nobody
Component: Contrib apps Version: dev
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: no UI/UX: no

Description

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',
 )

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 by Chris Beaven, 15 years ago

Triage Stage: UnreviewedAccepted

Yep, as documented here it should made be available.

comment:2 by Tobias McNulty, 15 years ago

Owner: changed from nobody to Tobias McNulty
Status: newassigned

by Tobias McNulty, 15 years ago

Attachment: ticket_13170.diff added

patch that adds get_level & set_level to all

comment:3 by Tobias McNulty, 15 years ago

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

comment:4 by Karen Tracey, 15 years ago

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 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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