Feedback & Notification
Notification Center with real-time server push
Notification Center
Notifications
Your deployment completed successfully.
2m agoAlice commented on your PR: 'Looks great!'
15m agoWeekly digest: 3 new components shipped.
1h agoScheduled maintenance Sunday 2am–4am UTC.
3h agoClick the bell icon above. Unread count badge updates in real-time. Clicking a notification marks it as read. Server pushes new notifications.
Real-Time Pattern
views.pypython
class DashboardView(LiveView):
def mount(self, request, **kwargs):
self.notifications = Notification.objects.filter(
user=request.user
).order_by('-created_at')[:20]
@event_handler()
def mark_notification_read(self, value='', **kwargs):
Notification.objects.filter(
id=value, user=self.request.user
).update(unread=False)
For real-time push from background tasks, use push_to_view() to send updates to connected clients without them polling.
tasks.pypython
# Celery / background task
def notify_user(user_id, message):
Notification.objects.create(
user_id=user_id, message=message
)
push_to_view(
user_id=user_id,
view_class=DashboardView,
event='refresh_notifications',
)