Opened 5 years ago

Closed 5 years ago

Last modified 4 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: UI/UX:


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 5 years ago.
style_messages_for_level.patch (1.4 KB) - added by sebastian_noack 5 years ago.

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by sebastian_noack

comment:1 Changed 5 years ago by piquadrat

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 5 years ago by jacob

  • milestone set to 1.3
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 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 5 years ago by sebastian_noack

comment:4 Changed 5 years ago by lukeplant

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12803

comment:5 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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