Gray Adams
Gray Adams

Reputation: 4117

How can I display a global alert in Django admin panel?

I don't want it to show up after performing an action, I want it to show up on all pages of the Django admin panel.

Is this possible?

Upvotes: 0

Views: 911

Answers (2)

Kye
Kye

Reputation: 4495

Is it a static message? I'd just override the necessary admin templates and not use django.contrib.messages as you may be tempted to - it may be confusing to the user.

Upvotes: 1

airstrike
airstrike

Reputation: 2401

A loooong time ago I used django-persistent-messages for this.

Users will get a message across the top of the page which will only go away after they dismiss it by clicking on an X icon. You can use different degrees of alertness (info, warning, error, critical) so it's pretty useful.

The one caveat is that, in order to make the messages persistent, they are linked to a user account. If your website uses anonymous users you will have to think of something else (perhaps a javascript approach with cookies or one of the more modern browser storage methods)

Upvotes: 0

Related Questions