Opened 10 years ago

Closed 10 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: UI/UX:


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 Changed 10 years ago by Ivan Giuliani

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)
                message="Your custom message here"
        return ret
Note: See TracTickets for help on using tickets.
Back to Top