Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#13652 closed (duplicate)

Support error user messages [PATCH]

Reported by: Sebastian Noack Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Currently user messages (django.contrib.auth.Message) as used by the admin, are always displayed with a success icon. But I also use ModelAdmin.message_user() to log failures or warnings. So I think we should have a way to flag user messages and show them different in the admin. I have written a patch, that adds a new column to the Message model indicating the type of the message (INFO or ERROR). The default is INFO, because of info message are rendered the same way as all messages are rendered at the moment. So this patch does not break any existing code. But the ModelAdmin.message_user() method got another optional argument, you can use to specify INFO or ERROR.

Attachments (2)

add_message_flag_to_message_model.patch (3.3 KB) - added by Sebastian Noack 9 years ago.
style_messages_for_level.patch (1.4 KB) - added by Sebastian Noack 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Sebastian Noack

comment:1 Changed 9 years ago by Benjamin Wohlwend

The Message model from contrib.auth has been deprecated in Django 1.2 (see, so the chances of any feature additions getting into trunk are pretty slim. The all new messages framework supports levels similarly to what you propose. I don't know if they are already used in the admin app, though.

comment:2 Changed 9 years ago by Jacob

milestone: 1.3
Triage Stage: UnreviewedAccepted

comment:3 Changed 9 years ago by Sebastian Noack

I have written the patch for django 1.1, so you can ignore it. ;) I have looked at the messages framework introduced with django 1.2. It looks great and yes it is used by the admin. But the admin does not care about the level right now. I have added a new patch for django 1.2, which uses the icon related to the level, when displaying messages in the admin. Since the admin is using the message framework, ModelAdmin.message_user(request, msg) just calls, msg). So I would recommend to deprecate ModelAdmin.message_user() in favour of info(), debug(), success(), warning() and error() from django.contrib.messages.

Changed 9 years ago by Sebastian Noack

comment:4 Changed 9 years ago by Luke Plant

Resolution: duplicate
Status: newclosed

Duplicate of #12803

comment:5 Changed 8 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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