Opened 16 years ago

Closed 16 years ago

#8684 closed (invalid)

Adding custom (succes/failure) messages to the admin site

Reported by: metzeltiger Owned by: nobody
Component: contrib.admin Version:
Severity: Keywords: message, notification
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you for example save a new object in the admin site this small yellow bar on top will appear telling you "everything's saved correctly".
It would be very useful if you were able to create your own custom messages here.

Change History (1)

comment:1 by Ivan Giuliani, 16 years ago

Resolution: invalid
Status: newclosed

You can do this by overriding ModelAdmin.response_add() (or .response_change), so closing as invalid. Follows an example, just for future reference:

class TestAdmin(admin.ModelAdmin):
    def response_add(self, request, obj, post_url_continue='../%s/'):
        ret = super(Model1Admin, self).response_add(request, obj, post_url_continue)
        request.user.get_and_delete_messages()
        request.user.message_set.create(
                message="Your custom message here"
        )
        return ret
Note: See TracTickets for help on using tickets.
Back to Top