#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 |
Description
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)
Change History (7)
by , 14 years ago
Attachment: | add_message_flag_to_message_model.patch added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
milestone: | → 1.3 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
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 django.contrib.messages.info(request, msg). So I would recommend to deprecate ModelAdmin.message_user() in favour of info(), debug(), success(), warning() and error() from django.contrib.messages.
by , 14 years ago
Attachment: | style_messages_for_level.patch added |
---|
The Message model from contrib.auth has been deprecated in Django 1.2 (see http://docs.djangoproject.com/en/dev/topics/auth/#messages), 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.