@notify_on_save — Postgres LISTEN/NOTIFY → UI
A model save reaches every connected reader's open page in ~50 ms. No Celery. No Redis pub/sub. No second service to operate.
Order feed (17 total)
listening
On Postgres, this would fan out to every open browser tab via NOTIFY realtime_order. Configure Postgres to try it.
| # | Customer | Total | Status | Time |
|---|---|---|---|---|
| 17 | Acme #4 | $79.96 | pending | 21:56:31 |
| 16 | Demo customer #16 | $319.84 | pending | 21:56:24 |
| 15 | Tyrell Corp | $159.92 | shipped | 05:54:31 |
| 14 | Cyberdyne | $139.93 | pending | 05:54:31 |
| 13 | Stark Industries | $119.94 | cancelled | 05:54:31 |
| 12 | Wayne Ent. | $99.95 | shipped | 05:54:31 |
| 11 | Umbrella Co | $79.96 | pending | 05:54:31 |
| 10 | Initech | $59.97 | cancelled | 05:54:31 |
| 9 | Globex Inc | $39.98 | shipped | 05:54:31 |
| 8 | Acme Corp | $19.99 | pending | 05:54:31 |
The whole pattern
Model
from djust.db import notify_on_save
@notify_on_save("realtime_order")
class Order(models.Model):
customer = models.CharField(max_length=200)
total = models.DecimalField(max_digits=10, decimal_places=2)
View
class OrderFeed(LiveView):
def mount(self, request, **kwargs):
self.listen("realtime_order")
self._refresh()
def handle_info(self, message):
if message["type"] == "db_notify":
self._refresh() # picks up the new save
See docs.djust.org/api/notify-on-save/ for the full guide including channel naming, signal teardown, and async listeners.