@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 (14 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 |
|---|---|---|---|---|
| 14 | Globex Field Ops | $199.00 | pending | 07:29:39 |
| 13 | Globex Lab | $149.00 | pending | 07:29:39 |
| 12 | Globex Tower | $99.00 | pending | 07:29:39 |
| 11 | Acme East | $199.00 | pending | 07:29:39 |
| 10 | Acme West | $149.00 | pending | 07:29:39 |
| 9 | Acme HQ | $99.00 | pending | 07:29:39 |
| 8 | Tyrell Corp | $159.92 | shipped | 04:30:19 |
| 7 | Cyberdyne | $139.93 | pending | 04:30:19 |
| 6 | Stark Industries | $119.94 | cancelled | 04:30:19 |
| 5 | Wayne Ent. | $99.95 | shipped | 04:30:19 |
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.